Save and Restore using DockSiteLayoutSerializer()

Docking/MDI for WPF Forum

Posted 12 years ago by Scott Doyle
Version: 11.2.0552
Avatar

I want to be able to save the Document Layout (Example: Side-by-Side Windows) and then restore the layout.

I have no issue with restoring the data.  My windows get displayed, but by default they are tabbed.

Here is my code to save my Document Windows

 

var dockSiteSerializer = new DockSiteLayoutSerializer();
dockSiteSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
return dockSiteSerializer.SaveToString(documents);

 

 I get the following xml:

 

<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="All">
	<AutoHideHost />
	<Content xsi:type="Workspace" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900">
		<Content xsi:type="TabbedMdiHost">
			<Content xsi:type="SplitContainer" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900" Orientation="Horizontal">
				<UIElement xsi:type="TabbedMdiContainer" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" SelectedWindowUniqueId="07a3dea9-9184-42eb-b58a-d2e4c08af0d4">
					<UIElement xsi:type="DocumentWindowRef" UniqueId="07a3dea9-9184-42eb-b58a-d2e4c08af0d4" />
				</UIElement>
				<UIElement xsi:type="TabbedMdiContainer" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" SelectedWindowUniqueId="23e0e2db-f3f5-40df-aa4f-1352a12e625b">
					<UIElement xsi:type="DocumentWindowRef" UniqueId="23e0e2db-f3f5-40df-aa4f-1352a12e625b" />
				</UIElement>
			</Content>
		</Content>
	</Content>
	<DocumentWindows>
		<DocumentWindow UniqueId="07a3dea9-9184-42eb-b58a-d2e4c08af0d4" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" IsOpen="true" LastState="Document" Name="X07a3dea9" State="Document" />
		<DocumentWindow UniqueId="23e0e2db-f3f5-40df-aa4f-1352a12e625b" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" IsOpen="true" LastState="Document" Name="X23e0e2db" State="Document" />
	</DocumentWindows>
</DockSiteLayout>

When data gets refreshed and I want to restore the layout I get a blank page when I restore the layout.  Here is the xml before I do a LoadFromString(layout, documents):

<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="All">
	<AutoHideHost />
	<Content xsi:type="Workspace" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900">
		<Content xsi:type="TabbedMdiHost">
			<Content xsi:type="TabbedMdiContainer" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900" SelectedWindowUniqueId="eb4ba382-2911-4851-995c-09cb3da314b0">
				<UIElement xsi:type="DocumentWindowRef" UniqueId="eb4ba382-2911-4851-995c-09cb3da314b0" />
				<UIElement xsi:type="DocumentWindowRef" UniqueId="cdb6dfa6-57cd-4e73-8041-697fd1612e0c" />
			</Content>
		</Content>
	</Content>
	<DocumentWindows>
		<DocumentWindow UniqueId="eb4ba382-2911-4851-995c-09cb3da314b0" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900" IsOpen="true" LastState="Document" Name="Xeb4ba382" State="Document" />
		<DocumentWindow UniqueId="cdb6dfa6-57cd-4e73-8041-697fd1612e0c" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900" IsOpen="true" LastState="Document" Name="Xcdb6dfa6" State="Document" />
	</DocumentWindows>
</DockSiteLayout>

I noticed that the UniqueID's are different.  Please help me with this issue.  Thanks!

Comments (4)

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

Hi Scott,

The layout information is match up using the Name property, so you must ensure that a DocumentWindow with the name "X07a3dea9" is registered with the DockSite before loading your layout. Otherwise it will not be use restored, unless you are using our lazy-loading feature.


Actipro Software Support

Posted 12 years ago by Scott Doyle
Avatar

I made the change, but the windows seem to still go away.  After loading the layout the documents collection is 0: LoadFromString(layout, documents);

I tried setting the DockingWindowDeserializationBehavior to Discard and AutoCreate and neither worked for me.

Here is my saved layout:

//Saved Layout.
<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="All">
	<AutoHideHost />
	<Content xsi:type="Workspace" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900">
		<Content xsi:type="TabbedMdiHost">
			<Content xsi:type="SplitContainer" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900" Orientation="Horizontal">
				<UIElement xsi:type="TabbedMdiContainer" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" SelectedWindowUniqueId="342e4fcd-2a8b-46c1-94c0-50040446460e">
					<UIElement xsi:type="DocumentWindowRef" UniqueId="342e4fcd-2a8b-46c1-94c0-50040446460e" />
				</UIElement>
				<UIElement xsi:type="TabbedMdiContainer" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" SelectedWindowUniqueId="a4e27923-ea04-43d3-8dcb-a5fa913afba0">
					<UIElement xsi:type="DocumentWindowRef" UniqueId="a4e27923-ea04-43d3-8dcb-a5fa913afba0" />
				</UIElement>
			</Content>
		</Content>
	</Content>
	<DocumentWindows>
		<DocumentWindow UniqueId="342e4fcd-2a8b-46c1-94c0-50040446460e" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" IsOpen="true" LastState="Document" Name="Slide0" State="Document" />
		<DocumentWindow UniqueId="a4e27923-ea04-43d3-8dcb-a5fa913afba0" AutoHideSize="495,900" DockedSize="495,900" DocumentSize="495,900" FloatingSize="495,900" Size="495,900" IsOpen="true" LastState="Document" Name="Slide1" State="Document" />
	</DocumentWindows>
</DockSiteLayout>

 

Here is my layout before I call the LoadFromString:

//Current Layout.
<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="All">
	<AutoHideHost />
	<Content xsi:type="Workspace" AutoHideSize="995,900" DockedSize="995,900" DocumentSize="995,900" FloatingSize="995,900" Size="995,900">
		<Content xsi:type="TabbedMdiHost">
			<Content xsi:type="TabbedMdiContainer" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" SelectedWindowUniqueId="ccf40cde-4816-4045-a745-1b0df10c6f00">
				<UIElement xsi:type="DocumentWindowRef" UniqueId="ccf40cde-4816-4045-a745-1b0df10c6f00" />
				<UIElement xsi:type="DocumentWindowRef" UniqueId="3fc692b0-aaa2-4c13-9957-f4537c625e9f" />
			</Content>
		</Content>
	</Content>
	<DocumentWindows>
		<DocumentWindow UniqueId="ccf40cde-4816-4045-a745-1b0df10c6f00" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Document" Name="Slide0" State="Document" />
		<DocumentWindow UniqueId="3fc692b0-aaa2-4c13-9957-f4537c625e9f" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Document" Name="Slide1" State="Document" />
	</DocumentWindows>
</DockSiteLayout>
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 12 years ago by Scott Doyle
Avatar

After creating a sample project, the windows were restored to their correct location. I did not realize that the LoadFromString() closed the existing windows and recreated them. After a little digging I noticed that I had an OnDocumentClosed Event that was removing my ViewModel data when the window gets closed.

The latest build of this product (v24.1.2) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.