Set owner of dialog to floated Tool Window

Docking/MDI for WPF Forum

Posted 2 years ago by Paul White
Version: 21.1.3
Avatar

Hi there

We have an application using Prism and Actipro Docking control and have everything working pretty much as we want, having adapted the Prism integration example code.  However one issue we are facing is with the positioning of modal dialogues.  We have a view in ToolWindow and usually it is floated and then moved to away from the main window to another monitor.  If a modal dialog is then shown from the view modal using Prism's DialogService it displayed over the main application window.  This is because the dialogue window Owner is being set to the application's main window by default.  We can override this behaviour in Prism but currently I cannot work out how to get a reference to the Window containing the viewmodel that is showing the dialogue in order to pass it to the dialogue service to set the Owner on the dialogue window.  We have a single DockSite in our main shell and a region assigned to it and a DockSiteRegionAdapter set up.   In the viewmodel I can access the injected RegionManager and get the docksite associated with the Region via the Behaviours. Debugging I can see the FloatingDockHosts and I think I can use the Parent property to get the a reference to Window but I cannot work out how to determine which of the FloatingDockHosts is hosting my viewmodel and it seems a fairly tortuous route anyway.  I presume there must be an easier way to do this and I am sure someone has had to face this problem before.

Cheers

Paul

Comments (1)

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

Hi Paul,

If you use a dockSite.ContainerFromItem(item) call where 'item' is your view-model, that should give you a DockingWindow-derived element instance.  Each DockingWindow has a DockHost property that gives you the DockHost and you could call something like Window.GetWindow(dockingWindow.DockHost) to get the WPF Window that contains the floating DockHost.  Does that give you what you need?


Actipro Software Support

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