Current position of a toolwindow?

Docking/MDI for WPF Forum

Posted 6 years ago by Peter Monadjemi - Developer, ActiveTraining
Version: 13.2.0592
Avatar

How can I get the current position of ToolWindow.

In lack of a LocationChanged event of the parent I have no idea where to search for.

Kind regards,

Peter

Software development is a craft driven by passion

Comments (8)

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

Hi Peter,

First, what sort of position information are you trying to get and why do you need it?  Position info shouldn't generally matter to you since you can use our serialization/deserialization layout features to save and restore how all the docking windows appear.


Actipro Software Support

Posted 6 years ago by Peter Monadjemi - Developer, ActiveTraining
Avatar

I would like to save the current position of each single ToolbarWindow in a text file so that I can restore the position of each ToolbarWindow the next time the app starts.

Solving that issue would be important for me.

 

Kind regards,

Peter

Software development is a craft driven by passion

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

Hi Peter,

That is exactly what our layout serialization features are for.  Several of our samples show it and there is a "Layout, Globalization, and Accessibility Features / Layout Serialization" topic in the Docking/MDI documentation as well that talks about how to use it.  Please check those out for more information.


Actipro Software Support

Posted 6 years ago by Peter Monadjemi - Developer, ActiveTraining
Avatar

Thank you very much. I wasnt sure what the layout serialization is good for.

Where can I find the samples? 

Regards,

Peter

Software development is a craft driven by passion

Posted 6 years ago by Peter Monadjemi - Developer, ActiveTraining
Avatar

I found the sample as part of the sample browser.

I have one more question though:

is it possible to read out just the position of each window? I don't want to restore the layout at once but just the position of certain windows depending on its content.

 

Regards,

Peter

Software development is a craft driven by passion

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

Hi Peter,

A layout will deserialize and restore everything inside of it from when the layout was saved.  You can't pick and choose what gets restored.

Once a docking window has been put in the layout in a session and if it is closed, it can be restored to its prior location via a call to its Open() or Activate() methods.  Note that the layout information is lost between application run sessions though, meaning if you run your app and call one of those methods prior to loading a layout (or having it in your default XAML layout), then it will go to a default location.


Actipro Software Support

Posted 6 years ago by Peter Monadjemi - Developer, ActiveTraining
Avatar

So, there is no way to restore the position of a single toolwindow (I don't mean a dockingwindow) by code?

And is there no way to get the position of a toolwindow? I tried several events but none  is fired while a toolwindow is moved. So I could store the current position of a toolwindow individually.

One last question that doesn't relate to my first question:

How can I restrict the movement of a toolwindow to its docking site? I don't want the user to be able to move a toolwindow outside the app window.

Kind regards,

Peter

Software development is a craft driven by passion

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

Hi Peter,

Positions aren't easy things to track since you could have extremely complex nested hierarchies.  When you close a tool window at runtime, it will leave a Track object in its place.  Then if you open the tool window again in the same application session, it will swap the tool window back in where that Track was.  Layout serialization will serialize all the Track information but again, it does it for the entire layout.  You can't save off that info for individual tool windows.

Tool windows can be programmatically docked around by using methods like Dock() or Float().  The ToolWindow class does have a GetDirectionRelativeToWorkspace method that might be somewhat helpful to you.  You could use that to get a general idea of where the tool window is but it won't be as exact as restoring to a Track or from a layout.

You can set the CanRaft property to false to prevent a tool window from floating.


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.