ToolWindowContainer and its Reference to DockSite

Docking/MDI for WPF Forum

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Version: 20.1.1
Avatar

I've run into an issue where intermittantly a ToolWindowContainer is loosing its reference to the DockSite and I don't know why or how to get that reference back.  I'm programmatically moving a single ToolWindow between two different ToolWindowContainers.  One always has another ToolWindow in it's collection (no problem with this one) while the other only has at most the one.  I'm using ToolWindowContainer.Windows.Add() and ToolWindowContainer.Windows.Remove() to faciliate the movement.  I tried just using Attach() but that didn't work at all.  The container that's loosing it DockSite reference is the one that can be empty.  I'm not sure if this is a bug or if I'm just doing something incorrectly and would appreciate some guidance.  

Comments (5)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rick,

You shouldn't be modifying the ToolWindowContainer.Windows collection as that is something used internally by us and initial XAML load.  Instead, you should be able to use methods like ToolWindow.Attach(IDockTarget) or ToolWindow.Dock(IDockTarget, Side) to programmatically move a ToolWindow.  The IDockTarget can be another open ToolWindow, ToolWindowContainer, Workspace, etc.  But you should never keep references to specify ToolWindowContainer instances since those are dynamically created and destroyed as layout changes occur.  You could get a current ToolWindowContainer reference (its base class actually) for a ToolWindow via ToolWindow.ParentContainer, but it's easier to just target a ToolWindow instead of its container.


Actipro Software Support

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

I did try Attach() and Dock() with no joy.  Attach only worked for the first move, say from container A to container B, but had no impact when trying to move again from B to A.  Dock didn't seem to do anything at all.  I'll take another stab at it and put together a sample project that illustrates the issues if I can't get it working.

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rick,

That all should be working ok.  We're not aware of any bugs in those methods.  If you do run into something you think might not be working as intended, please let us know how to reproduce it in one of our samples.  Or a new simple sample project of your own is fine too if you want to send that to our ticket system.  Thanks!


Actipro Software Support

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

I just entered a ticket and included a small sample project that illustrates the issue.

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rick,

Thanks for the sample.  It looks like you are naming ToolWindowContainer instances and targeting those.  That is a no-no since per above, containers are dynamically created and described as layout changes occur.  Only DockSite, DocumentWindow, ToolWindow, Workspace, and TabbedMdiHost objects remain through layout changes and are safe to name and target.  If you change your code to Attach or Dock around ToolWindow instances instead of ToolWindowContainers, it works fine.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.