Layout serialization

Docking/MDI for WPF Forum

Posted 2 years ago by Yuki
Version: 22.1.2
Avatar

Hello,

I would like to save and load layout of DocumentWindow and ToolWindow separately.

  1. Save layout of DocumentWindow
  2. Save layout of ToolWindow
  3. Load layout of DocumentWindow
  4. Load layout of ToolWindow


I'm using DockSiteLayoutSerializer.CanKeepExistingDocumentWindowsOpen = true, but DocumentWindow`s layout doesn't keep when execute step-4.

Is it possible to keep it when load layout separately?

I'm going to send simple sample project by email.

Would you please check it?

Comments (15)

Posted 2 years ago by Yuki
Avatar

2. Save layout of ToolWindow

This layout data contains ToolWindow which is displaying as document window.

DocumentWindow`s layout doesn't keep when execute step-4.

LazyLoad data also is not kept.

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

Hello,

At this time we don't have a document-only serialization option.  The only two options right now are All or ToolWindowsOnly.  Therefore the closest thing we can get to what you want to do is to load the "All" layout first (which has documents and clears the existing MDI hierarchy as it restores), and then load the "ToolWindowsOnly" one next.

Part of the problem in the sample you sent us is that your layout serializer always had SerializationBehavior = DockSiteSerializationBehavior.All, so your tool windows layout was effectively also clearing the MDI area.  You want to change your sample's methods to be more like this:

private void SaveLayoutMenuItem_Click(object sender, RoutedEventArgs e) {
    layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
    documentLayoutData = layoutSerializer.SaveToString(dockSite);

    layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.ToolWindowsOnly;
    toolLayoutData = layoutSerializer.SaveToString(dockSite);
}

private void LoadLayoutMenuItem_Click(object sender, RoutedEventArgs e) {
    if (string.IsNullOrEmpty(documentLayoutData) || string.IsNullOrEmpty(toolLayoutData))
        return;

    layoutSerializer.CanKeepExistingDocumentWindowsOpen = true;

    layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
    layoutSerializer.LoadFromString(documentLayoutData, dockSite);

    layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.ToolWindowsOnly;
    layoutSerializer.LoadFromString(toolLayoutData, dockSite);
}

private void DefaultLayoutMenuItem_Click(object sender, RoutedEventArgs e) {
    if (string.IsNullOrEmpty(defaultLayoutData))
        return;

    layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
    layoutSerializer.LoadFromString(defaultLayoutData, dockSite);
}

If you do that, then it will be pretty close to what you want.  The only minor issue will be that tool windows that were in the MDI area will end up in the active MDI container instead of where they previously were, since ToolWindowsOnly serialization behavior doesn't restore MDI structure, only the All behavior does.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

Thank you for replying. I got it.

The only minor issue will be that tool windows that were in the MDI area will end up in the active MDI container instead of where they previously were, since ToolWindowsOnly serialization behavior doesn't restore MDI structure, only the All behavior does.

Will this minor issue be modified at next maintenance release?

Posted 2 years ago by Yuki
Avatar

Hello,

Therefore the closest thing we can get to what you want to do is to load the "All" layout first (which has documents and clears the existing MDI hierarchy as it restores), and then load the "ToolWindowsOnly" one next.

When load the "ToolWindowsOnly", it seems that stored layout data(LazyLoad) which is loaded by "All" will be cleared.

Would you please check it?

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

Hello,

1) For the issue where the ToolWindowsOnly serialization behavior doesn't restore the MDI area, that's tough to fix because the current tabbed MDI layout and container hierarchy (originally restored by the All deserialization before your ToolWindowsOnly deserialization) might be drastically different and incompatible with the tabbed MDI layout within the ToolWindowsOnly layout data.  Some tabbed MDI containers may or may not be present already, and may in different orientations/hierarchies.  That's why ToolWindowsOnly deserialization currently restores tool windows in MDI to the active tabbed MDI container instead.

2) Yes, lazy load data is cleared on each deserialization.  Therefore the ToolWindowsOnly deserialization would clear out any lazy load data from the prior All deserialization.  This clearing is done because otherwise lazy load data would accumulate over time when layout deserializations were performed.  Most people just do a single deserialization at a time, so this hasn't really been an issue before.  Are you looking to keep DocumentWindow-only lazy load data on ToolWindowsOnly deserializations?

We are open to thoughts on how to improve all this to better suit your needs, while recognizing the challenges faced in changes.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

Thank you for replying.

I hope strongly the issue will be modified because this function is very important for our Application.

Would you please let me know if there are any updates?

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

Hello,

This will be in the next maintenance release v22.1.3:

  • Updated tool window-only layout deserializations to not clear lazy-load data for document windows.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

Thank you for replying.

It is good news!

Would you please continue to consider issue#1?

Posted 2 years ago by Yuki
Avatar

Hello,

  • Updated tool window-only layout deserializations to not clear lazy-load data for document windows.

I checked with 22.1.3-beta.7, but lazy-load data was cleared when deserialize by tool window only mode.

Would you please check it?

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

Hello,

We were able to debug this scenario with some modifications to your sample project and found second place in the code that was clearing the document window breadcrumbs for unknown document windows.  We've fixed this for the next maintenance release and uploaded the fix as beta.8.  Please modify the same URL you used before but use "beta.8" instead of "beta.7".  Let us know the result once you test it on your end.  Thanks!


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

Thank you for your support.

  • Updated tool window-only layout deserializations to not clear lazy-load data for document windows.

I confirmed it at "beta.8". Thanks!

Please let me know if there are any updates of issue#1.

1) For the issue where the ToolWindowsOnly serialization behavior doesn't restore the MDI area, that's tough to fix because the current tabbed MDI layout and container hierarchy (originally restored by the All deserialization before your ToolWindowsOnly deserialization) might be drastically different and incompatible with the tabbed MDI layout within the ToolWindowsOnly layout data.  Some tabbed MDI containers may or may not be present already, and may in different orientations/hierarchies.  That's why ToolWindowsOnly deserialization currently restores tool windows in MDI to the active tabbed MDI container instead.

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

I'm sorry but there are no updates for #1.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar
  1. Save layout of DocumentWindow
  2. Save layout of ToolWindow
  3. Load layout of DocumentWindow
  4. Load layout of ToolWindow

Regarding to #1, I'm trying to merge 2 layout data of 3 and 4 by myself and load layout at once.

But below exception occur sometimes. 

- System.InvalidOperationException: Specific element is already the logical child of another element. Disconnect is first

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

That exception can happen if you try loading an element but it's already loaded in another place in the visual tree.  Maybe in your modifications, you are specifying the same docking window in two separate locations?


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

I'll send my sample project.

Would you please advice me?

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.