
I am hoping to be able to save/restore the arrangement of the windows.
Here is the setup of the DockSite.
<docking:DockSite x:Name="dockSite" CanDocumentWindowsFloat="True" FloatingWindowTitle="Mongoose Editor"
AreDocumentWindowsDestroyedOnClose="False"
WindowsClosing="dockSite_WindowsClosing" Loaded="dockSite_Loaded" >
<docking:SplitContainer>
<docking:Workspace Name="dockingWorkspace">
<docking:TabbedMdiHost x:Name="tabbedMdiHost" TabStripPlacement="Bottom">
<docking:TabbedMdiContainer x:Name="tabbedMdiContainer">
<docking:DocumentWindow x:Name="CommandWindow" Title="Commands" >
Here is the serialize/deserialize code.
private string GetDockSiteLayoutPath()
{
var dir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\MongooseEditor";
return $"{dir}\\Layout_{dockSite.Name}.xml";
}
private void LoadDockSiteLayout(DockSite dockSite)
{
if (dockSite == null)
return;
var serializer = new DockSiteLayoutSerializer
{
DocumentWindowDeserializationBehavior = DockingWindowDeserializationBehavior.AutoCreate,
SerializationBehavior = DockSiteSerializationBehavior.All,
ToolWindowDeserializationBehavior = DockingWindowDeserializationBehavior.AutoCreate,
};
var path = GetDockSiteLayoutPath();
if (File.Exists(path))
serializer.LoadFromFile(path, dockSite);
}
private void SaveDockSiteLayout(DockSite dockSite)
{
if (dockSite == null)
return;
var serializer = new DockSiteLayoutSerializer
{
DocumentWindowDeserializationBehavior = DockingWindowDeserializationBehavior.AutoCreate,
SerializationBehavior = DockSiteSerializationBehavior.All,
ToolWindowDeserializationBehavior = DockingWindowDeserializationBehavior.AutoCreate,
};
var path = GetDockSiteLayoutPath();
serializer.SaveToFile(path, dockSite);
}
private void dockSite_WindowsClosing(object sender, DockingWindowsEventArgs e)
{
SaveDockSiteLayout(sender as DockSite);
}
private void dockSite_Loaded(object sender, RoutedEventArgs e)
{
LoadDockSiteLayout(sender as DockSite);
}
and the serializer seems to only save the default layout without any information about the document windows docked location or size. It just shows the windows as all filling the workspace.
<DockSiteLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationFormat="All" Version="2">
<AutoHideHost />
<Content xsi:type="Workspace">
<Content xsi:type="TabbedMdiHost">
<Content xsi:type="TabbedMdiContainer" DockedSize="1583,1153" SelectedWindowUniqueId="7674065c-c937-4fdb-b58c-526dbc7f985d">
<UIElement xsi:type="DocumentWindowRef" UniqueId="7674065c-c937-4fdb-b58c-526dbc7f985d" />
<UIElement xsi:type="DocumentWindowRef" UniqueId="dc2625e8-5e2e-4a5c-b64c-c2839a3f9e95" />
<UIElement xsi:type="DocumentWindowRef" UniqueId="aa4e7c86-f51b-4670-b02d-149fb8297e87" />
</Content>
</Content>
</Content>
<DocumentWindows>
<DocumentWindow UniqueId="7674065c-c937-4fdb-b58c-526dbc7f985d" Name="CommandWindow" ContainerDockedSize="1583,1153" IsOpen="true" State="Document" />
<DocumentWindow UniqueId="dc2625e8-5e2e-4a5c-b64c-c2839a3f9e95" Name="UnitsUsedWindow" ContainerDockedSize="1583,1153" IsOpen="true" State="Document" />
<DocumentWindow UniqueId="aa4e7c86-f51b-4670-b02d-149fb8297e87" Name="BugCreationTab" ContainerDockedSize="1583,1153" IsOpen="true" State="Document" />
</DocumentWindows>
</DockSiteLayout>
I had actually docked the UnitsUsedWindow below the CommandWindow before serialization.
Thanks for the help.