How to set first position and size of floating window?

Docking/MDI for WPF Forum

Posted 1 year ago by Yuki
Version: 22.1.3
Avatar

Hello,

How to set first position and size of floating window?

I'd like to show tool window as floating and set position and size.

And I'm using DockSite with MVVM pattern.

Comments (5)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

This documentation topic talks about the Float method you can use to specify location and size.  That is a method right on the DockingWindow class.

As for using the MVVM pattern, that is possible too.  You can use a property on your tool window view model to bind to the DockingWindow.ContainerDockedSize property, as that is what determines the tool window's floating window size.  Then use the default locations feature where you handle the DockSite.WindowDefaultLocationRequested event, something like this:

dockSite.WindowDefaultLocationRequested += (sender, e) => {
	if ((e.Window is ToolWindow toolWindow) && (toolWindow.DataContext is ToolItemViewModel viewModel)) {
		// TODO: Add more logic here to see if the view model says it should float and where.
		//   Then execute these kinds of lines:
		e.FloatingLocation = new Point(100, 10);
		e.ShouldFloat = true;
	}
};


Actipro Software Support

Posted 1 year ago by Yuki
Avatar

Hello,

Thank you for replying.

I was able to set default position of floating window.

How to set default size of floating window?

I'd like to set default size of both document and tool window.

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I'm glad you were able to get the location set properly.  Per the previous reply, the default size for the floating window should be value of the DockingWindow.ContainerDockedSize properly.  You can bind a property on your view model to DockingWindow.ContainerDockedSize via the docking window Style you use.


Actipro Software Support

Posted 1 year ago by Yuki
Avatar

Hello,

Thank you for replying.

I'm sorry, I missed comment of DockingWindow.ContainerDockedSize properly.

I was able to set default size and position of floating window.

However, when I clicked "Move to Main Document Group" menu of right click menu, WindowDefaultLocationRequested was executed again and the window move to default position, not main document group.

Would you please check it?

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

For things like this, please tell us the exact steps to reproduce this in one of our samples, or send our support address a new simple sample project that shows it happening.  Then we can debug the issue and see what's going on.  If you email a project, be sure to exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

The latest build of this product (v24.1.1) 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.