Problem restoring Layout when no DocumentWindow was open

Docking/MDI for WPF Forum

Posted 11 years ago by Christian Prochnow
Version: 12.2.0570
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

Hi,

we have a problem restoring the DockSite layout when no DocumentWindow was created before creating ToolWindows.
If we create a DocumentWindow before we create ToolWindows, the layout is restored correctly.

Here is the layout that will get restored correctly (DocumentWindow created before any ToolWindows):

<DockSiteLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationFormat="ToolWindowsOnly">
	<AutoHideHost>
		<AutoHideTabStrip Side="Right">
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200">
				<UIElement xsi:type="Track" UniqueId="20f84369-ecc2-40d1-bd2e-03d916b902dc" />
			</ToolWindowContainer>
		</AutoHideTabStrip>
	</AutoHideHost>
	<Content xsi:type="SplitContainer" AutoHideSize="1133,785" DockedSize="1154,785" DocumentSize="1133,785" FloatingSize="1133,785" Size="1154,785" Orientation="Horizontal">
		<UIElement xsi:type="Workspace" AutoHideSize="1133,785" DockedSize="1133,785" DocumentSize="949,785" FloatingSize="1133,785" Size="949,785">
			<Content xsi:type="TabbedMdiHost">
				<Content xsi:type="TabbedMdiContainer" AutoHideSize="949,785" DockedSize="949,785" DocumentSize="949,785" FloatingSize="949,785" Size="949,785" SelectedWindowUniqueId="f530da86-5246-445a-a515-95bcb03f3406" />
			</Content>
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="200,785" DockedSize="200,785" DocumentSize="200,785" FloatingSize="200,785" Size="200,785" SelectedWindowUniqueId="879d860e-5c58-46b3-86a5-b33a03d00ef7">
			<UIElement xsi:type="ToolWindowRef" UniqueId="879d860e-5c58-46b3-86a5-b33a03d00ef7" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="200,785" DockedSize="200,785" DocumentSize="200,785" FloatingSize="200,785" Size="200,785">
			<UIElement xsi:type="Track" UniqueId="20f84369-ecc2-40d1-bd2e-03d916b902dc" />
		</UIElement>
	</Content>
	<ToolWindows>
		<ToolWindow UniqueId="7f465692-7459-4777-bfc8-b3749678b2f1" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="false" LastState="Docked" State="Docked" />
		<ToolWindow UniqueId="879d860e-5c58-46b3-86a5-b33a03d00ef7" AutoHideSize="200,200" DockedSize="200,785" DocumentSize="200,200" FloatingSize="200,200" Size="200,785" IsOpen="true" LastState="Docked" Name="ObjectSearchToolWindow" State="Docked" />
		<ToolWindow UniqueId="245c442b-2b48-4301-86aa-7496b7b991df" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="false" LastState="Docked" Name="DocumentViewerToolWindow" State="Docked" />
		<ToolWindow UniqueId="931c8f05-31ae-4a79-922e-3186bd8b8f08" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="false" LastState="Docked" Name="NavigationToolWindow" State="Docked" />
		<ToolWindow UniqueId="03f83973-e7ff-4bb6-be7b-51e93ded419e" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="false" LastState="Docked" Name="PropertyEditor" State="Docked" />
	</ToolWindows>
</DockSiteLayout>

 

 The following layout will not restore any open ToolWindows. This layout was saved without creating a DocumentWindow before any ToolWindow:

<DockSiteLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationFormat="ToolWindowsOnly">
	<AutoHideHost />
	<Content xsi:type="SplitContainer" AutoHideSize="1154,785" DockedSize="1154,785" DocumentSize="1154,785" FloatingSize="1154,785" Size="1154,785" Orientation="Horizontal">
		<UIElement xsi:type="Workspace" AutoHideSize="949,785" DockedSize="949,785" DocumentSize="949,785" FloatingSize="949,785" Size="949,785">
			<Content xsi:type="TabbedMdiHost" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="200,785" DockedSize="200,785" DocumentSize="200,785" FloatingSize="200,785" Size="200,785" SelectedWindowUniqueId="964c3a79-5ad0-41df-b96e-a958b9fb46b1">
			<UIElement xsi:type="ToolWindowRef" UniqueId="964c3a79-5ad0-41df-b96e-a958b9fb46b1" />
		</UIElement>
	</Content>
	<ToolWindows>
		<ToolWindow UniqueId="964c3a79-5ad0-41df-b96e-a958b9fb46b1" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Docked" Name="ObjectSearchToolWindow" State="Docked" />
		<ToolWindow UniqueId="9e5fc0d6-198f-4c04-9577-8543eae61cff" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="false" LastState="Docked" State="Docked" />
	</ToolWindows>
</DockSiteLayout>

 

I have to note that our DockSite is created in code:

var dockSite = new DockSite
                {
                    Name = "DockSite"
                };

var splitContainer = new SplitContainer();
dockSite.Content = splitContainer;

var workspace = new Workspace
                {
                    Name = "Workspace"
                };

splitContainer.Children.Add(workspace);
_workspace.SwitchToTabbedMdi();

_window.Content = dockSite;

 

Thanks for your help.

 

Best regards,

 

Christian Prochnow

Comments (1)

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

Hi Christian,

As long as the tool window is already known, it will show up.  If your tool window isn't known to the DockSite when you load that layout, it won't show unless you set options to auto-create, etc.  This is described a bit in the Layout Serialization documentation topic.

For instance I tested with this and it worked fine:

var tw = new ToolWindow(mainDockSite, "ObjectSearchToolWindow", "Search", null, "test");
var serializer = new ActiproSoftware.Windows.Controls.Docking.Serialization.DockSiteLayoutSerializer();
serializer.LoadFromFile(@"C:\Users\Actipro\Desktop\testlayout.xml", mainDockSite);


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.