In my application I have several different "worksheets", which basically is a different combination of open windows and land their layout.
Each of these worksheets are serialized layouts, using the LayoutSerializer.
What I am now trying to accomplish, is to add a new ToolWindow to all the different layouts. To accomplish this, I create the new ToolWindow and register it with the DockSite, then I iterate through each layout, load it, call Open() on the ToolWindow, save the layout and move on to the next layout.
The issue is that the newly added window doesn't get docked in the SplitContainer beside the other existing ToolWindows, but instead gets docked in the same ToolWindowContainer as the last ToolWindow, so that it shares space with that ToolWindow, and tabs appear below the ToolWindow.
This code should give you an idea of what is happening:
var layoutBeforeAddingNewWindow = _layoutSerializer.SaveToString(dockSite);
var toolWindow = new ToolWindow(this.dockSite, serializationId, displayName, null, uiElement)
{
CanAutoHide = false,
HasOptionsButton = false
};
toolWindow.Dock(dockSite, Side.Right);
_layoutSerializer.LoadFromString(layoutBeforeAddingNewWindow, dockSite);
toolWindow.Open();
var newLayout = _layoutSerializer.SaveToString(dockSite);
Expected result, if adding 1 window to a worksheet that already contains 1 window. Each ToolWindow in their own ToolWindowContainer:
<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="SplitContainer" Orientation="Horizontal" DockedSize="6,200">
<UIElement xsi:type="ToolWindowContainer" DockedSize="0,200" SelectedWindowUniqueId="3df06b6a-8a2d-4125-b331-5b70d66a4fce">
<UIElement xsi:type="ToolWindowRef" UniqueId="3df06b6a-8a2d-4125-b331-5b70d66a4fce" />
</UIElement>
<UIElement xsi:type="ToolWindowContainer" DockedSize="0,200" SelectedWindowUniqueId="0d0ce408-2232-4e18-9c11-0f560f4e0d4c">
<UIElement xsi:type="ToolWindowRef" UniqueId="0d0ce408-2232-4e18-9c11-0f560f4e0d4c" />
</UIElement>
</Content>
<ToolWindows>
<ToolWindow UniqueId="3df06b6a-8a2d-4125-b331-5b70d66a4fce" SerializationId="9f354282-c01b-464b-bad6-f058c7dc33db" ContainerDockedSize="0,200" IsOpen="true" State="Docked" />
<ToolWindow UniqueId="0d0ce408-2232-4e18-9c11-0f560f4e0d4c" SerializationId="a54db06f-f48b-47fe-bb1e-c35dc4314e8c" ContainerDockedSize="0,200" IsOpen="true" State="Docked" />
</ToolWindows>
</DockSiteLayout>
Actual, two ToolWindows inside a ToolWindowContainer:
<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="SplitContainer" Orientation="Horizontal" DockedSize="6,200">
<UIElement xsi:type="ToolWindowContainer" DockedSize="0,200" SelectedWindowUniqueId="33895f26-464a-43e3-89af-f5facf826e71">
<UIElement xsi:type="ToolWindowRef" UniqueId="33895f26-464a-43e3-89af-f5facf826e71" />
<UIElement xsi:type="ToolWindowRef" UniqueId="2fc4f5e2-0bbb-474f-9956-2422f6e4bc5c" />
</UIElement>
<UIElement xsi:type="ToolWindowContainer" DockedSize="0,0" />
<UIElement xsi:type="ToolWindowContainer" DockedSize="0,0" />
</Content>
<ToolWindows>
<ToolWindow UniqueId="33895f26-464a-43e3-89af-f5facf826e71" SerializationId="1f8f2f9d-294e-4bc1-8baa-24e7ad4ef47b" ContainerDockedSize="0,200" IsOpen="true" LastActiveDateTime="2017-10-05T16:36:58.028624+02:00" State="Docked" />
<ToolWindow UniqueId="2fc4f5e2-0bbb-474f-9956-2422f6e4bc5c" SerializationId="b2f4cdee-7715-4401-a1eb-a3bfb1b20c23" ContainerDockedSize="0,200" IsOpen="true" State="Docked" />
</ToolWindows>
</DockSiteLayout>
Hope you understood what I am trying to accomplish, and have a suggestion as to how to get this to work as I described.
- Farris