Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1150
Load only a part of the layout?
posted

Hi,

I am currently using the free AvalonDock component for the docking functionalities of my application, but encountered a hard to fix issue in regard to the layout save and restore functionality, so I was wondering if your component might be a suitable replacement.

In my application, I have a document area plus dockable and floatable content. Each document is of a specific type, which requires certain windows (dockable and floatable content) to be displayed near the document area. So whenever the user selects a different tab, I need to load a specific window layout.

So when loading and saving layouts, I'd like to exclude the document area from modifications. I only want to re-arrange the windows around the document area, the document area itself should keep the same tabs. AvalonDock can be used to have this behaviour (with minor modifications), but it has the issue that it generates a new "root layout object" when restoring the layout which then replaces the old object in the logical tree. This is a highly expensive operation (http://blogs.microsoft.co.il/blogs/tomershamam/archive/2009/09/11/wpf-performance-sweets-contentcontrol-content-null.aspx), since some of the documents in my application have a rather large logical tree (also including an XamGrid for example). So if I load the layout on a tab change, it can take more than a second to finish loading the layout (does not sound much, but for a simple tab change this is clearly too much).

Would your control suffer from the same issue? Loading only a part of the layout could solve the issue, as well as not replacing the logical tree.

Parents
  • 54937
    Offline posted

    floele said:

    In my application, I have a document area plus dockable and floatable content. Each document is of a specific type, which requires certain windows (dockable and floatable content) to be displayed near the document area. So whenever the user selects a different tab, I need to load a specific window layout.

    Loading a layout seems like overkill for such a behavior. Why wouldn't you just change the Visibility of the panes (i.e. collapse ones that should not be displayed and make others visible)?

    floele said:
    So when loading and saving layouts, I'd like to exclude the document area from modifications. I only want to re-arrange the windows around the document area, the document area itself should keep the same tabs.

    When loading a layout the xamDockManager will only move the panes that are referenced by the layout so if the documents aren't part of the layout then they will be left alone. The panes in the layout will be based on the panes within the xamDockManager at the time you called SaveLayout and will exclude any panes whose SaveInLayout is false. Note, such panes may still be reparented during a layout if the ancestor tree changes, etc.

    floele said:
    AvalonDock can be used to have this behaviour (with minor modifications), but it has the issue that it generates a new "root layout object" when restoring the layout which then replaces the old object in the logical tree. This is a highly expensive operation (http://blogs.microsoft.co.il/blogs/tomershamam/archive/2009/09/11/wpf-performance-sweets-contentcontrol-content-null.aspx), since some of the documents in my application have a rather large logical tree (also including an XamGrid for example). So if I load the layout on a tab change, it can take more than a second to finish loading the layout (does not sound much, but for a simple tab change this is clearly too much).

    When the xamDockManager loads a layout panes are going to get unload/loaded and the logical tree may change since the panes are being moved around. ContentPanes are logical children of the SplitPane/TabGroupPane that they belong to. Also panes in floating windows are not in the logical tree of the xamDockManager since they are parented within a separate WPF Window (at least in a regular WPF application).

    floele said:

    Would your control suffer from the same issue? Loading only a part of the layout could solve the issue, as well as not replacing the logical tree.

    It sounds like if your issue relates to the reparenting of the elements (i.e. getting unloaded/loaded) and changing of the logical tree then it may well have the same issue. Any time that elements are moved there is going to be a performance hit as WPF is doing a lot of work - propogating inherited property changes, notifying elements of loading/unloading, hwndsource  changes, ancestor change notifications, etc. With regards to loading a partial layout we don't support that per se but as I mentioned you can exclude things (e.g. your documents - panes within the DocumentContentHost) from the layout and so they will be left in the control and they probably will not be affected when you load the layout as long as the layout doesn't reference those documents. As I mentioned though another way would be to simply keep the other panes (the ones specific to each document type) in the xamDockManager but set the Visibility of the ContentPanes to Collapsed/Visible as needed based on the ActiveDocument of the DocumentContentHost.

Reply Children