Restore docksite layout

Docking/MDI for WPF Forum

Posted 2 years ago by joe
Version: 16.1.0633
Avatar

I’m confused on how to restore a docksite layout correctly. Here is what I’m currently doing:


1) Create workspace view model. This view model restores the documents and tool models. Here we will end up with a list of documents and a list of panels. They all have the correct ContentID from the last session.
2) Create window and set the data context. This window has the dock site. This dock site will bind to the documents and panels list from the view model.
3) Show the main window.
4) Restore the dock sites layout.


This is the only way I could get anything to work. It also has a side effect I don’t like because you see the window with the default layout and then it restores the layout from disk causing everything to shuffle around. This seems slow because it must destroy and recreate everything from scratch.

What I would like is to have everything loaded and bound before I call the show so the window comes up looking right.

I’ve tried to use lazy loading with no luck. Here how I went about it:


1) Create window.
2) Load layout on the dock site (I set the deserialization behavior to lazyload)
3) Create workspace view model. This view model restores the documents and tool models. Here we will end up with a list of documents and a list of panels. They all have the correct ContentID from the last session.
4) Set the data context to the workspace view model.
5) Show the window.


Now at step four I expected that when it binds to the view model it would look up into its lazy data and find an already created docking window and assign the new model. But what happens is I only see the default layout.

Let me know what I’m doing wrong please!
Joe

Comments (3)

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

Hi Joe,

How about if when you initialize your view models at the start, you make sure all their IsOpen properties are false.  Does that help prevent the initial default layout from occurring?


Actipro Software Support

Posted 2 years ago by joe
Avatar

If i set there IsOpen property to false it still doesn't work. It now shows no panels or documents now. Here s the code base code.

mainWindow = new MainWindow();
mainWindow.LoadLayout();
mainWindow.DataContext = mainWindowVM;
mainWindow.Show();

I don't see any loading code in the docking system that when the docksite binds to the workspace view model to get a list of documents and panels, that it looks up into the lazy loading data.

Here is my loading code:

var layoutSerializer = new DockSiteLayoutSerializer();
layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
layoutSerializer.ToolWindowDeserializationBehavior = DockingWindowDeserializationBehavior.LazyLoad;
layoutSerializer.DocumentWindowDeserializationBehavior = DockingWindowDeserializationBehavior.LazyLoad;
layoutSerializer.LoadFromStream(stream, dockSite);

I assume after this LoadFromStream we should see a bunch of blank panels and documents. Then when bindings happens the content will start to fill out.

 

Let me know if i'm not thinking about this right?

Joe

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

Hi Joe,

The DockSite really needs to be Loaded before you can load a layout into it.  Try delaying the LoadLayout() call until the DockSite.Loaded event fires the first time and see if that helps.

If not, please maka new simple sample project that shows the issue and email it to our support address.  We'll have a look at it and can see what's going on.  Be sure to reference this thread in your email and rename the .zip file extension so it doesn't get spam blocked.


Actipro Software Support

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.