DockSiteLayout incorrect when placed in a UserControl

Docking/MDI for WPF Forum

Posted 3 months ago by Michael Janulaitis
Version: 19.1.0673
Platform: .NET 4.7
Environment: Windows 10 (64-bit)
Avatar

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="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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>
    <UIElement xsi:type="SplitContainer" Orientation="Vertical" DockedSize="952,200">
      <UIElement xsi:type="Workspace">
        <Content xsi:type="TabbedMdiHost" />
      </UIElement>
      <UIElement xsi:type="ToolWindowContainer" DockedSize="952,207" SelectedWindowUniqueId="0985843c-ca4c-4e42-99d5-05b80b47d80e">
        <UIElement xsi:type="ToolWindowRef" UniqueId="0985843c-ca4c-4e42-99d5-05b80b47d80e" />
      </UIElement>
    </UIElement>
  </Content>
  <ToolWindows>
    <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" />
  </ToolWindows>
</DockSiteLayout>

[Modified 3 months ago]

Comments (3)

Posted 3 months ago by Michael Janulaitis
Avatar

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 3 months ago by Michael Janulaitis
Avatar

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

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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 (v2019.1 build 0685) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.