Problem with DockSiteLayoutSerializer!

Docking/MDI for WPF Forum

Posted 10 years ago by Hejian Lin
Version: 14.2.0610
Platform: .NET 4.5
Environment: Windows 8 (64-bit)
Avatar

Hi Actipro Support

We got a problem about serializing DockSite to string with DockSiteLayoutSerializer.

I am using the following code to create the ToolWindow:

ToolWindow toolWindow = new ToolWindow(_mainWindowDockSite,
                                       windowKey,
                                       windowTitle,
                                       windowImageSource,
                                       windowInfo.ContentHostUserControl)
                                       {
                                         HasTitleBar = hasTitleBar,
                                         HasOptions = hasOptions,
                                         CanDrag = canDrag,
                                         CanRaft = canFloat,
                                         CanAttach = canAttach,
                                         CanAutoHide = canAutoHide,
                                         CanBecomeDocument = canBecomeDocument,
                                         CanDockTop = canDockHostTop,
                                         CanDockBottom = canDockHostBottom,
                                         CanDockLeft = canDockHostLeft,
                                         CanDockRight = canDockHostRight,
                                         CanClose = canClose,
                                       };

toolWindow.Dock(_mainWindowDockSite, ToDirection(dockingDirection));
toolWindow.Open();
toolWindow.Activate(true);

And using the following code to get the serialized string:

string _inlineWindowsLayout = new DockSiteLayoutSerializer().SaveToString(dockSite);

_inlineWindowsLayout will be save to the user.config file, which will be used for restoring when the application restarts.

Every time when I do the folowing things, the saved serialized string was appended with some "track" xml element:
1. open the application
2. create tool window
3. close the tool window
4. close the application

followings are the save _inlineWindowsLayout with different time of created and closed tool window

Open app, create tool wnd, close tool wnd, close app once:

<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="ToolWindowsOnly">
	<AutoHideHost>
		<AutoHideTabStrip Side="Bottom">
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" SelectedWindowUniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8">
				<UIElement xsi:type="ToolWindowRef" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
			</ToolWindowContainer>
		</AutoHideTabStrip>
	</AutoHideHost>
	<Content xsi:type="SplitContainer" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,877" FloatingSize="1910,856" Size="1910,856" Orientation="Vertical">
		<UIElement xsi:type="Workspace" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,856" FloatingSize="1910,856" Size="1910,856">
			<Content xsi:type="TabbedMdiHost" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
		</UIElement>
	</Content>
	<ToolWindows>
		<ToolWindow UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Docked" Name="_00f7881e_825d_4b72_9c5a_4288ef3703c2" StandardMdiBounds="0,0,300,200" State="AutoHide" />
	</ToolWindows>
</DockSiteLayout>

 Open app, create tool wnd, close tool wnd, close app twice:

<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="ToolWindowsOnly">
	<AutoHideHost>
		<AutoHideTabStrip Side="Bottom">
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200">
				<UIElement xsi:type="Track" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
			</ToolWindowContainer>
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" SelectedWindowUniqueId="8e204c69-c86f-4a97-a7b5-898057060c13">
				<UIElement xsi:type="ToolWindowRef" UniqueId="8e204c69-c86f-4a97-a7b5-898057060c13" />
			</ToolWindowContainer>
		</AutoHideTabStrip>
	</AutoHideHost>
	<Content xsi:type="SplitContainer" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,877" FloatingSize="1910,856" Size="1910,856" Orientation="Vertical">
		<UIElement xsi:type="Workspace" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,856" FloatingSize="1910,856" Size="1910,856">
			<Content xsi:type="TabbedMdiHost" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="8e204c69-c86f-4a97-a7b5-898057060c13" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
		</UIElement>
	</Content>
	<ToolWindows>
		<ToolWindow UniqueId="8e204c69-c86f-4a97-a7b5-898057060c13" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Docked" Name="_00f7881e_825d_4b72_9c5a_4288ef3703c2" StandardMdiBounds="0,0,300,200" State="AutoHide" />
	</ToolWindows>
</DockSiteLayout>

 Open app, create tool wnd, close tool wnd, close app three times:

<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="ToolWindowsOnly">
	<AutoHideHost>
		<AutoHideTabStrip Side="Bottom">
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200">
				<UIElement xsi:type="Track" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
			</ToolWindowContainer>
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200">
				<UIElement xsi:type="Track" UniqueId="8e204c69-c86f-4a97-a7b5-898057060c13" />
			</ToolWindowContainer>
			<ToolWindowContainer AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" SelectedWindowUniqueId="08ede896-434f-443a-8929-9f0aec8cbc36">
				<UIElement xsi:type="ToolWindowRef" UniqueId="08ede896-434f-443a-8929-9f0aec8cbc36" />
			</ToolWindowContainer>
		</AutoHideTabStrip>
	</AutoHideHost>
	<Content xsi:type="SplitContainer" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,877" FloatingSize="1910,856" Size="1910,856" Orientation="Vertical">
		<UIElement xsi:type="Workspace" AutoHideSize="1910,856" DockedSize="1910,856" DocumentSize="1910,856" FloatingSize="1910,856" Size="1910,856">
			<Content xsi:type="TabbedMdiHost" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="08ede896-434f-443a-8929-9f0aec8cbc36" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="8e204c69-c86f-4a97-a7b5-898057060c13" />
		</UIElement>
		<UIElement xsi:type="ToolWindowContainer" AutoHideSize="1910,200" DockedSize="1910,200" DocumentSize="1910,200" FloatingSize="1910,200" Size="1910,200">
			<UIElement xsi:type="Track" UniqueId="c1128aec-7f78-46a4-9668-277d1527d2d8" />
		</UIElement>
	</Content>
	<ToolWindows>
		<ToolWindow UniqueId="08ede896-434f-443a-8929-9f0aec8cbc36" AutoHideSize="200,200" DockedSize="200,200" DocumentSize="200,200" FloatingSize="200,200" Size="200,200" IsOpen="true" LastState="Docked" Name="_00f7881e_825d_4b72_9c5a_4288ef3703c2" StandardMdiBounds="0,0,300,200" State="AutoHide" />
	</ToolWindows>
</DockSiteLayout>

 .................

 

May I know why and the solution!

Comments (3)

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

Hello,

Tracks are like breadcrumbs that are invisible and persist in the layout so that a tool window knows where it should restore to if it returns to a state.  For instance, a track in a docked tool window container will be replaced with the actual related tool window if the tool window is reopened into a docking state.

It sounds like you might be creating this tool window programmatically and making a new unique ID for it each session.  If you do that, you probably want to call toolWindow.Destroy() before writing out your layout file.  That way, the tool window will be removed from the visual layout, removed from the DockSite, and all its tracks should be removed as well.


Actipro Software Support

Posted 10 years ago by Hejian Lin
Avatar

Thanks for your reply.

As you say, "making a new unique ID for it each session". Does it mean that I can specify the unique ID for the created  tool window? If can, then how to do it?

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

Hello, no but I believe the unique ID can be restored from layout deserialization if a tool window with the same name as one that's already in the DockSite is found, or if it is lazy loaded later.


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.