DockSiteLayout incorrect when placed in a UserControl

Docking/MDI for WPF Forum

Posted 4 years ago by Michael Janulaitis - Corner Bowl Software
Version: 19.1.0673
Platform: .NET 4.7
Environment: Windows 10 (64-bit)

I have working DockSiteLayout serialization, however, I have just moved my DockSite to a child UserControl,  now my default layout does not load properly and when I save my layout using the exact same code as when the DockSite was contained within a Window it does not load properly after restart.  What do I need to do to get the layout to work correctly in a UserControl?  Here is my default load layout which now displays the tools windows in the wrong location on initial startup:

<DockSiteLayout xmlns:xsi="" xmlns:xsd="" SerializationFormat="ToolWindowsOnly" Version="2">
  <AutoHideHost />
  <Content xsi:type="SplitContainer" Orientation="Horizontal" DockedSize="1274,904.04">
    <UIElement xsi:type="ToolWindowContainer" DockedSize="320,1054" SelectedWindowUniqueId="860b7199-4fdb-46d5-879e-21fc4303dc1c">
      <UIElement xsi:type="ToolWindowRef" UniqueId="860b7199-4fdb-46d5-879e-21fc4303dc1c" />
    <UIElement xsi:type="SplitContainer" Orientation="Vertical" DockedSize="952,200">
      <UIElement xsi:type="Workspace">
        <Content xsi:type="TabbedMdiHost" />
      <UIElement xsi:type="ToolWindowContainer" DockedSize="952,207" SelectedWindowUniqueId="0985843c-ca4c-4e42-99d5-05b80b47d80e">
        <UIElement xsi:type="ToolWindowRef" UniqueId="0985843c-ca4c-4e42-99d5-05b80b47d80e" />
    <ToolWindow UniqueId="860b7199-4fdb-46d5-879e-21fc4303dc1c" SerializationId="ExplorerViewModel" ContainerDockedSize="320,1054" IsOpen="true" LastActiveDateTime="2018-05-30T19:46:51.1562247-06:00" State="Docked" />
    <ToolWindow UniqueId="0985843c-ca4c-4e42-99d5-05b80b47d80e" SerializationId="ServerOutputViewModel" ContainerDockedSize="952,207" IsOpen="true" LastActiveDateTime="2018-05-30T19:46:54.6344206-06:00" State="Docked" />

[Modified 4 years ago]

Comments (3)

Posted 4 years ago by Michael Janulaitis - Corner Bowl Software

If I delay the load then tool windows briefly display in the wrong location then using the following code the windows unload then reload in the correct location:

SynchronizationContext.Current.Post((x) =>{new DockSiteLayoutSerializer().LoadFromFile(DockFilePath, dockSite);}, null);
Answer - Posted 4 years ago by Michael Janulaitis - Corner Bowl Software

I moved the LoadFromFile to the UserControl Loaded event handler.  All is working correctly now.

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

Hi Michael,

Yes I was just about to suggest that it should work fine in a UserControl as long as the UserControl has been Loaded (at or after its Loaded event fires) when you deserialize the layout.

Actipro Software Support

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.