Load ToolWindow from resource file

Docking/MDI for WPF Forum

Posted 14 years ago by Phillip OShea
Version: 9.2.0510
I am looking to load a ToolWindow defined in an XAML resource file. Here is what it looks like:

    <TextBox Text="This Window displayed correctly." />
Here is how I load the XAML file:

var myWindow = ( ToolWindow )Application.LoadComponent( new Uri( "MyWindow.xaml", UriKind.Relative ) );
Loading the control is fine, the issue arises when I attempt to Dock the window to my DockSite. Calling Dock and then Open throws an exception:

This operation is invalid since the DockingWindow has not yet been registered with a DockSite.

If I do some fancy footwork prior to calling Dock and Open, I can get it to load properly:

var temp = RootDockSite.Content;
RootDockSite.Content = myWindow;
RootDockSite.Content = temp;
My question is, how do I do this cleanly?!

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Philip,

There are two ways to do this:

1) Use the ToolWindow constructor that takes a DockSite instance. The parameterless one is for internal use only.


2) Ensure your ToolWindow is in the ToolWindows collection of your DockSite before you dock it.

Either of those should work.

Actipro Software Support

Posted 14 years ago by Phillip OShea
Adding the window reference to the DockSite's ToolWindow collection worked perfectly.

Thanks for your help.
The latest build of this product (v24.1.2) 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.