How to persist layout of closed tool windows

Docking/MDI for WPF Forum

Posted 4 years ago by Andrew Hanlon
Version: 14.2.0611
Avatar

I am using databinding for my docking windows, and I am using the built-in layout serialization to persist the layout.

If I have a tool window open and I serialize the layout, when I next restore the application (deserialize) I can open the window at any time (lazily load) and it will open at the previous location (as expected). This works great.

If I close (destroy) the same tool window and open it again (i.e. a window with the same unique name), then it opens in a default location and state, which is not desired. 

If I close (destroy) the tool window, then serialize the layout, when I next restore the applciation (deserialize) then the tool window opens to a default location and state, which again is not desired.

How can I, or what is the appropriate strategy to, persist the layout of closed tool windows both within the same and accross multitple sessions?

Thank you,

Andrew Hanlon

Comments (3)

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

Hi Andrew,

The problem here is that you are destroying the tool windows, which removes all trace of them (and their related layout tracking bits) from the DockSite.  If you Close() the tool window instead of calling Destroy() on it, then the tool window and its layout data tracking will remain live in the DockSite, even though it isn't currently visible.  That should get it working for you.


Actipro Software Support

Posted 4 years ago by Andrew Hanlon
Avatar

Thank you for the reply. 

How does the 'close without destroying' work with the databound/mvvm docking windows scenario?

When I close a window I do not want to maintain the ViewModel in memory, so I remove the viewModel from the bound collection. When adding the viewmodel back into the bound collection (even though the same name is set) a new window is generated, and therefore does not use the persisted layout. 

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

Hi Andrew,

I believe that by removing the view model, you will indirectly cause a destroy.  You would not be able to remove the view model if you wish to keep the tool window and its layout data associated with the DockSite.

If you have any suggestions on improving this for the future (please be detailed), we are currently working on reworking a large portion of Docking/MDI's internals to make it an even better product than it already is, adding a lot of new features along the way too.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) 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.