From 87408e20639f38d1a3244cab2b31486e9e2e0b78 Mon Sep 17 00:00:00 2001 From: Khaos66 Date: Fri, 19 Mar 2021 14:20:52 +0100 Subject: [PATCH] Don't create FloatingWindows twice The list was filled to late. DockingManager_Loaded could occure again before the list of created elements was filled --- source/Components/AvalonDock/DockingManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/Components/AvalonDock/DockingManager.cs b/source/Components/AvalonDock/DockingManager.cs index 1c68e2c4..f7819482 100644 --- a/source/Components/AvalonDock/DockingManager.cs +++ b/source/Components/AvalonDock/DockingManager.cs @@ -1562,6 +1562,9 @@ internal UIElement CreateUIElementForModel(ILayoutElement model) }; newFW.SetParentToMainWindowOf(this); + // Fill list before calling Show (issue #254) + _fwList.Add(newFW); + // Floating Window can also contain only Pane Groups at its base (issue #27) so we check for // RootPanel (which is a LayoutAnchorablePaneGroup) and make sure the window is positioned back // in current (or nearest) monitor @@ -1602,6 +1605,9 @@ internal UIElement CreateUIElementForModel(ILayoutElement model) }; newFW.SetParentToMainWindowOf(this); + // Fill list before calling Show (issue #254) + _fwList.Add(newFW); + var paneForExtensions = modelFW.RootPanel; if (paneForExtensions != null) { @@ -1957,10 +1963,10 @@ private void DockingManager_Loaded(object sender, RoutedEventArgs e) } _fwHiddenList.Clear(); - // load floating windows not already loaded! (issue #59) + // load floating windows not already loaded! (issue #59 & #254) var items = new List(Layout.FloatingWindows.Where(fw => !_fwList.Any(fwc => fwc.Model == fw))); foreach (var fw in items) - _fwList.Add(CreateUIElementForModel(fw) as LayoutFloatingWindowControl); + CreateUIElementForModel(fw); //create the overlaywindow if it's possible if (IsVisible)