Layout Deserialisation Issues

Docking/MDI for WPF Forum

Posted 3 years ago by Gareth Parris - Software Developer, McLaren
Version: 16.1.0633
Avatar

Hi, are you aware of any deserialisation issues or gotchas when loading in a saved docksite layout with inner docksites? We are finding that when we reload the layouts the windows are automatically resizing themselves pages (inner docksites) are *sometimes* loading in a different order to what they were originally.

Checking the XML shows the order and sizes are correct but onloading it sometimes gets altered. We've not been able to pin down exactly if this is specifically an Actipro issue yet or our own serialization problem. I just wanted to ask if you have an advice of what to look out for?

Thanks!

Comments (11)

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

Hi Gareth,

We're not aware of any issues like that.  If you are loading an outer dock site layout, plus inner dock site layouts, I'd recommend doing them in that order (outer first).  That would help prevent any sizing changes that could possibly occur in the inner dock sites. 

But the fact that windows are loading out of order seems to indicate that something else is going on.  We haven't really seen that before so we'd need a sample project that shows it happening to debug it.


Actipro Software Support

Posted 3 years ago by Mark Bonner
Avatar

Further to Gareth's last comments...

Question: On deserialising page child displays, why are we loosing layout width when using ToolWindow objects?

History

We had changed our functionality a couple of months again, by replacing Page content to use ToolWindow objects rather than previously DocumentWindow objects.

Scenario to create the problem

Create test layouts: One page containing 2 child screens, with the first child filling most of the screen and the second child filling the remainder.

Run Old Application that uses DockWindow implementation

- Old layout deserializes and opens correctly

- New layout throws exception with message: Cannot place windows in MDI since no MDI host was located as the direct child of the DockSite's Workspace

Run New Application that user ToolWindow implementation

- Old version displays both child displays with equal width, but both taking display 2 width and docked on the right. Most of the page content is empty.

- New version displays both child displays with equal width, each taking 50% of the available page content space. WHY IS THIS HAPPENING?

 

Fragments of XML serialised content

Old version using DocumentWindow:

<Content xsi:type="Workspace">
<Content xsi:type="TabbedMdiHost">
<Content xsi:type="SplitContainer" Orientation="Horizontal" DockedSize="1674,200">
<UIElement xsi:type="TabbedMdiContainer" DockedSize="1471,200" SelectedWindowUniqueId="fe51163e-886a-47e9-839e-25a1bfb0bb50">
<UIElement xsi:type="DocumentWindowRef" UniqueId="fe51163e-886a-47e9-839e-25a1bfb0bb50" />
</UIElement>
<UIElement xsi:type="TabbedMdiContainer" SelectedWindowUniqueId="9b39a155-65cf-4447-9611-fd14d2fd17e0">
<UIElement xsi:type="DocumentWindowRef" UniqueId="9b39a155-65cf-4447-9611-fd14d2fd17e0" />
</UIElement>
</Content>
</Content>
</Content>
<DocumentWindows>
<DocumentWindow UniqueId="fe51163e-886a-47e9-839e-25a1bfb0bb50" SerializationId="Waveform4931a01a82884156b101452a3f490be9" ContainerDockedSize="1471,200" IsOpen="true" State="Document" />
<DocumentWindow UniqueId="9b39a155-65cf-4447-9611-fd14d2fd17e0" SerializationId="Waveform531217a0e2f24c579a10293875734ea4" IsOpen="true" State="Document" />
</DocumentWindows>

New Version using ToolWindow:

<Content xsi:type="SplitContainer" Orientation="Horizontal" DockedSize="1674,907">
<UIElement xsi:type="ToolWindowContainer" DockedSize="1471,907" SelectedWindowUniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e">
<UIElement xsi:type="ToolWindowRef" UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" />
</UIElement>
<UIElement xsi:type="ToolWindowContainer" SelectedWindowUniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b">
<UIElement xsi:type="ToolWindowRef" UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" />
</UIElement>
</Content>
<ToolWindows>
<ToolWindow UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" SerializationId="Waveformc95d8a233a8c4883b23efb04c30c8289" ContainerDockedSize="1471,907" IsOpen="true" State="Docked" />
<ToolWindow UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" SerializationId="Waveformff5c8fe973b34efbbf43aa621f0d37bd" IsOpen="true" State="Docked" />
</ToolWindows>

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

Hi Mark,

For scenario-oriented questions like this, it's always best to make a new simple sample project that shows the issue happening and email that to our support address so we can see what you see.

For the first question about the "no MDI host" issue, that is because the old pre-2016.1 version allowed some controls between a MDI host and its ancestor Workspace.  Whereas in the 2016.1 version, ths MDI host must be a direct child of the Workspace.  If you saw that error, then you must not have had a MDI host as a direct child of your Workspace.

For the second question with tool windows filling the entire  dock site, it's because you are using tool window inner-fill mode there.  You don't have a Workspace in the layout, and since there is no Workspace, all the tool windows will fill up the entire space.  When a Workspace control is in the dock site, tool windows will dock around it.  A workspace can directly contain an MDI host if you are using our MDI features, or it can contain any other control you wish if you are not using our MDI features.


Actipro Software Support

Posted 3 years ago by Mark Bonner
Avatar

Hi,

I get the desired layout affect if I wrap with a Workspace and TabbedMdiHost by manually modifying my persisted layout and then deserialise (see below). How can I include this items in the xaml or programmatically so the layout is generated accordingly?

 

<SerializedLayout>&lt;DockSiteLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationFormat="All" Version="2"&gt;
&lt;AutoHideHost /&gt;
&lt;Content xsi:type="Workspace"&gt;
&lt;Content xsi:type="TabbedMdiHost"&gt;
&lt;Content xsi:type="SplitContainer" Orientation="Horizontal" DockedSize="1674,907"&gt;
&lt;UIElement xsi:type="ToolWindowContainer" DockedSize="1471,907" SelectedWindowUniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e"&gt;
&lt;UIElement xsi:type="ToolWindowRef" UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" /&gt;
&lt;/UIElement&gt;
&lt;UIElement xsi:type="ToolWindowContainer" SelectedWindowUniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b"&gt;
&lt;UIElement xsi:type="ToolWindowRef" UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" /&gt;
&lt;/UIElement&gt;
&lt;/Content&gt;
&lt;/Content&gt;
&lt;/Content&gt;
&lt;ToolWindows&gt;
&lt;ToolWindow UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" SerializationId="Waveformc95d8a233a8c4883b23efb04c30c8289" ContainerDockedSize="1471,907" IsOpen="true" State="Docked" /&gt;
&lt;ToolWindow UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" SerializationId="Waveformff5c8fe973b34efbbf43aa621f0d37bd" IsOpen="true" State="Docked" /&gt;
&lt;/ToolWindows&gt;
&lt;/DockSiteLayout&gt;</SerializedLayout>

Kind regards,

Mark

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

Hi Mark,

If you do have a Workspace in your layout (normally you'd have one defined in XAML initially) then it should be getting serialized, even in tool window only layouts.  We see that working ok in our Layout Serialization QuickStart and haven't had any other reports of that not working properly (it's a commonly used feature). 

I'm not sure how you're opening your tool windows but if you do it programmatically, then just start with a XAML layout like this:

<docking:DockSite>
  <docking:Workspace />
</docking:DockSite>

Maybe that's what you're missing?  Because you should never have to manually alter the XML layout data.

If you think there is a bug here, please make a new simple sample that shows it and send that to our support address so we can debug it and see what's happening.  In your email, reference this thread and rename the .zip file extension of what you send so it doesn't get spam blocked.


Actipro Software Support

Posted 3 years ago by Mark Bonner
Avatar

Hi,

Unfortunately including <docking:Workspace /> doesn't fix the problem.

Our Page is inherited from a DockSite and needs to contain multiple ToolWindow objects to achieve the desired layout effect. A fragment of the existing functionality - including the commented Workspace tag suggested - can be seen below.

<local:PageDockSite x:Name="PageDockSite"
ToolItemsSource="{Binding Displays}"
ToolItemContainerStyle="{StaticResource DisplayStyle}"
.....additional property
>

<!--<docking:Workspace />--><local:PageDockSite.Switcher>

<docking:StandardSwitcher AreDocumentsVisible="False" />
</local:PageDockSite.Switcher>

</local:PageDockSite>

...

<Style x:Key="DisplayStyle"
TargetType="docking:ToolWindow"
BasedOn="{StaticResource DockingWindowStyle}"/>

<Style x:Key="DockingWindowStyle"
TargetType="docking:DockingWindow"/>

 

However, from the previous message we need to obtain a serialized output in which Workbook and TabbedMdiHost contain the ToolWindow children. Modifying the serialized file and then deserializing loads as expected. 

<SerializedLayout>&lt;DockSiteLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationFormat="All" Version="2"&gt;
&lt;AutoHideHost /&gt;
&lt;Content xsi:type="Workspace"&gt;
&lt;Content xsi:type="TabbedMdiHost"&gt;
&lt;Content xsi:type="SplitContainer" Orientation="Horizontal" DockedSize="1674,907"&gt;
&lt;UIElement xsi:type="ToolWindowContainer" DockedSize="1471,907" SelectedWindowUniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e"&gt;
&lt;UIElement xsi:type="ToolWindowRef" UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" /&gt;
&lt;/UIElement&gt;
&lt;UIElement xsi:type="ToolWindowContainer" SelectedWindowUniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b"&gt;
&lt;UIElement xsi:type="ToolWindowRef" UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" /&gt;
&lt;/UIElement&gt;
&lt;/Content&gt;
&lt;/Content&gt;
&lt;/Content&gt;
&lt;ToolWindows&gt;
&lt;ToolWindow UniqueId="24ff4532-10b5-48b7-9c34-f811f7d22e5e" SerializationId="Waveformc95d8a233a8c4883b23efb04c30c8289" ContainerDockedSize="1471,907" IsOpen="true" State="Docked" /&gt;
&lt;ToolWindow UniqueId="7f1e526a-7bd4-4a13-ad2a-66c2f6f6b99b" SerializationId="Waveformff5c8fe973b34efbbf43aa621f0d37bd" IsOpen="true" State="Docked" /&gt;
&lt;/ToolWindows&gt;
&lt;/DockSiteLayout&gt;</SerializedLayout>

Posted 3 years ago by Mark Bonner
Avatar

Hi,

Further to my previous comment and further investigation of docking functionality. Our existing approach uses the ToolItemsSource, so follows the MVVM approach. However, we need to programmatically insert the ToolWindow objects with the Workspace and TabbedMdiHost.

If I follow the approach in your ProgrammaticLayout sample (see below), my PrimaryDockHost is null? But if I change to (MyPageDockSite.Child as Workspace).Content = mdiHost, the ToolWindows still don't appear nested inside the Workspace and TabbedMdiHost when serialized?

// Add a Workspace
MyPageDockSite.Child = new Workspace();

// Add a TabbedMdiHost
var mdiHost = new TabbedMdiHost();
MyPageDockSite.PrimaryDockHost.Workspace.Content = mdiHost;

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

Hi Mark,

It would be helpful if you could supply a screenshot showing how you want things to look so that we can clearly understand if you are looking to have tabbed MDI or docked tool windows.

Based on today's messages, it seems like you want to have a DockSite / Workspace / TabbedMdiHost setup.  If you are wanting to have a tabbed MDI appearance, then why not use DocumentWindows instead of ToolWindows?  DocumentWindows can be created from MVVM too, just like you are doing with ToolWindows.  From your original message, it seems like you might have had an error with using DocumentWindows in 2016.1?  If that is the case, please send our support@actiprosoftware.com address a new simple sample project that shows the problem and we can debug it to see what's wrong.

But the point is that you should never be manually modifying the serialized XML layout data.  Perhaps there's a simple configuration issue you have in your app.  It's hard to tell from code in a forum though.  We need a simple sample showing the problem.


Actipro Software Support

Posted 3 years ago by Gareth Parris - Software Developer, McLaren
Avatar

Hi guys, the problem is that document windows do not give us the style that we need. We need each child window title to take up the full width of each window. The document tab style just doesn't work for us. We also needed to customise the tool window header and you made some changes that allowed us to do this. 

Its a weird problem that seems okay if we revert to document windows but doesn't if we use tool windows.

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

Hi Gareth,

Ok, thanks for the clarification on why you need to use tool windows... it's for the title bar.  Why can't you just use tool window inner-fill then, since that is similar to tabbed MDI, but is done through tool windows (and no Workspace) and has tool window appearance?

Mark was showing a scenario where he had modified the serialized XML layout so that ToolWindowContainers were in TabbedMdiHost, but that's not a supported control hierarchy. 

If you can clarify what the issue is with tool window inner-fill, that would be appreciated.  Screenshots and/or a sample project would make this a lot easier to understand on our end.


Actipro Software Support

Posted 3 years ago by Mark Bonner
Avatar

Please refer to the document emailed to support@actiprosoftware.com from mark.bonner@mclaren.com.

If the document doesn't help, could we arrange a chat conversation or even a remote desktop connection?

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.