Open tool at same location as ist was before being close.

Docking/MDI for WPF Forum

Posted 6 years ago by Ulrich Bürgi
Version: 13.1.0581
Avatar

Hi,

I have a tabbed MDI DockSite, which acts as a Prism region. Each window (view) has a unique name, so (lazy) layout serializtaion / deserialization works just fine when it is applied for the first time. However, when I close a tool via region.Remove(view) and open it again, the tool gets located at the default location and not at the previous one. I suppose the applied layout only works once per view.

Is there a way to persistently close and open the tool at the same location?

Comments (5)

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

Hi Ulrich,

Offhand I believe that region.Remove(view) is probably telling DockSite to remove the related tool window and destroy it as well, which deletes any layout data associated with it.  I think that you would want to not call region.Remove(view) and instead call ToolWindow.Close().  That will keep the tool window's layout data around but will hide it from the UI.  Then when you add the view back to ActiveViews again, it should reopen in the correct location.


Actipro Software Support

Posted 6 years ago by Ulrich Bürgi
Avatar

That's what I feared. The problem is that we heavily rely on the Prism concepts and it would somewhat break our current design if we had to differentiate between hiding and closing a tool.

Isn't there the possibilty to cache and reapply the layout data for one window only? Similar to how the layout serialization / deserialization works.

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

Hi Ulrich,

Our Prism interop assembly is fully open source and is up on our CodePlex site.  You can download it and modify it however you need to support alternate behavior.

Basically what's going on by default is that the DockSite.ToolItemsSource gets bound to the region.Views collection.  So when you remove a view, you are telling DockSite to destroy the tool window. 

You could alter this perhaps so that you have some other class in its place that stores the full list of views and when one is removed in your real collection, watch for that update and just "close" it in the interop assembly code instead of removing it from the collection bound to ToolItemsSource.

As for your other question, we don't have a way to cache layout data for a single tool window before it's destroyed so that it can be restored later.  If you want to do that, you need to update the code to close to tool window instead of destroying it.


Actipro Software Support

Posted 6 years ago by Ulrich Bürgi
Avatar

Ok, thank you for the response. We will adjust our view handling in such a way that we can use the "close" approach.

Posted 6 years ago by keshav bansal
Avatar

Hi Ulrich,

You can use the smart functios of the toolwindow like.

Toolwindow.Close() will close the toolwindow.

Toolwindow.Activate() will display the toolwindow from where it was closed.

 

Thanks

Keshav

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