How to know which window become floating in FloatingWindowOpening event

Docking/MDI for WPF Forum

Posted 2 years ago by Yuki
Version: 22.1.3
Avatar

Hello,

Would you please let me know how to know which window become floating in FloatingWindowOpening event?

I'm trying as the following now.

private void DockSite_FloatingWindowOpening(object? sender, FloatingWindowOpeningEventArgs e)
        {
            IEnumerable<DockingWindow>? floatingWindows;
            if (e.DockHostChild is Workspace workspace
                && workspace.Content is TabbedMdiHost tabbedMdiHost
                && tabbedMdiHost.Child is TabbedMdiContainer tabbedMdiContainer)
            {
                // DocumentWindow
                floatingWindows = tabbedMdiContainer.Windows.Where(x => x.IsFloating);
            }
            else if (e.DockHostChild is ToolWindowContainer toolWindowContainer)
            {
                // ToolWindow
                floatingWindows = toolWindowContainer.Windows.Where(x => x.IsFloating);
            }
            else
            {
            }
        }

Comments (1)

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

Hello,

If this opening event is for a floating window open commit (not a drag preview), the e.DockHost.Child property will return the root object being floated.  For tool windows, this would be a ToolWindowContainer.  For tabbed documents, it would be a Workspace. 

I think a lot of the logic you provided above will work as-is.  But you don't need the Where() LINQ calls since everything in those containers is part of this floating operation.


Actipro Software Support

The latest build of this product (v24.1.3) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.