Find center of docked ToolWindow

Docking/MDI for WPF Forum

Posted 5 years ago by James Perry
Version: 14.1.0602
Avatar

I have a button in a toolwindow which launches a smal dialog.
I want that dialog to be centered in the toolwindow.

i tried:

myDialog.Owner = Window.GetWindow(this.ToolWindow);
myDialog.WindowStarupLocation = WindowStartupLocation.CenterOwner;
myDialog.showDialog();

This works when the toolWindow is floating and will center the dialog on the center of the owner window.

If the ToolWindow is docked, then it ends up centering on the MainWindow instead of the smaller-ToolWindow that is docked within the mainwindow.

Any idea how to do it?

I could set the Dialog's "Top" and "Left" properties, if i just had some way to get at the location i want.

Comments (1)

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

Hi James,

Since tool windows themselves don't inherit Window, you would have to manually position the dialog.  You could probably get the element that is the ToolWindow.Content and find its midpoint.  Then call PointToScreen on that and center your dialog over that point.  I would think that logic would do it.


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.