From 50f595106037fb32e7c44a682b61e135cbd6a13d Mon Sep 17 00:00:00 2001 From: Dmitry Vodich Date: Thu, 5 Dec 2019 16:04:17 +0300 Subject: [PATCH] Resolve #98 with floating window without a content shown as black rectangle --- .../LayoutAnchorableFloatingWindowControl.cs | 11 +++++++++ .../Xceed.Wpf.AvalonDock/DockingManager.cs | 23 ++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index 38bc2829..7d1809a1 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -61,6 +61,8 @@ internal LayoutAnchorableFloatingWindowControl(LayoutAnchorableFloatingWindow mo { root.Updated += OnRootUpdated; } + + _model.IsVisibleChanged += _model_IsVisibleChanged; } private void OnRootUpdated(object sender, EventArgs e) @@ -194,6 +196,7 @@ protected override void OnClosed(EventArgs e) BindingOperations.ClearBinding(_model, VisibilityProperty); _model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged); + _model.IsVisibleChanged -= _model_IsVisibleChanged; Activated -= LayoutAnchorableFloatingWindowControl_Activated; IsVisibleChanged -= this.LayoutAnchorableFloatingWindowControl_IsVisibleChanged; BindingOperations.ClearBinding(this, VisibilityProperty); @@ -285,6 +288,14 @@ private void _model_PropertyChanged(object sender, System.ComponentModel.Propert } } + private void _model_IsVisibleChanged(object sender, EventArgs e) + { + if (!this.IsVisible && _model.IsVisible) + { + this.Show(); + } + } + private void CreateOverlayWindow() { if (_overlayWindow == null) diff --git a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs index 3c8b8b50..3fc71bd2 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs @@ -195,7 +195,17 @@ protected virtual void OnLayoutChanged(LayoutRoot oldLayout, LayoutRoot newLayou fw.WindowState = WindowState.Maximized; } else - fw.Show(); + { + if (fw.Content != null || (fw.Model as LayoutAnchorableFloatingWindow)?.IsVisible == true) + { + fw.Show(); + } + else + { + fw.Hide(); + } + } + //fw.Owner = Window.GetWindow(this); //fw.SetParentToMainWindowOf(this); } @@ -2100,8 +2110,15 @@ internal UIElement CreateUIElementForModel(ILayoutElement model) Dispatcher.BeginInvoke(new Action(() => { - newFW.Show(); - }), DispatcherPriority.Send); + if (newFW.Content != null || (newFW.Model as LayoutAnchorableFloatingWindow)?.IsVisible == true) + { + newFW.Show(); + } + else + { + newFW.Hide(); + } + }), DispatcherPriority.Send); if (panegroup != null && panegroup.IsMaximized) {