From 1f5cf8b47bcaf27028b12b181d86e15627dbed1e Mon Sep 17 00:00:00 2001 From: Dirkster99 Date: Fri, 10 May 2019 17:22:45 +0200 Subject: [PATCH] Fix for Issue #27 Reposition Floating Window based on LayoutAnchorablePane OR LayoutAnchorablePaneGroup as RootLayout Element https://github.com/Dirkster99/AvalonDock/issues/27 --- .../Xceed.Wpf.AvalonDock/DockingManager.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs index 289e25da..3682c264 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs @@ -2080,6 +2080,21 @@ internal UIElement CreateUIElementForModel( ILayoutElement model ) newFW.Width = paneForExtensions.FloatingWidth; newFW.Height = paneForExtensions.FloatingHeight; } + else + { + // Floating Window can also contain only Pane Groups at its base (issue #27) so we check for that + // and make sure the window is position back to where it was before (or the nearest monitor) + var panegroup = modelFW.RootPanel.Children.OfType().FirstOrDefault(); + if (panegroup != null) + { + panegroup.KeepInsideNearestMonitor(); // Check position is valid in current setup + + newFW.Left = panegroup.FloatingLeft; // Position the window to previous or nearest valid position + newFW.Top = panegroup.FloatingTop; + newFW.Width = panegroup.FloatingWidth; + newFW.Height = panegroup.FloatingHeight; + } + } newFW.ShowInTaskbar = false;