From dfa21a9c5805b6329d43a2da9bb40e3b8836aea5 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 20 Sep 2022 11:55:21 +0200 Subject: [PATCH] Prevents a known bug in WPF If a childwindow ist opened and closed and this control is closed the main window is minimized The workaround with setting the owner to null is not working, therefor Activate is used https://stackoverflow.com/questions/19156373/closing-child-window-minimizes-parent --- .../Controls/LayoutFloatingWindowControl.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/Components/AvalonDock/Controls/LayoutFloatingWindowControl.cs b/source/Components/AvalonDock/Controls/LayoutFloatingWindowControl.cs index 71d0602e..ce134df3 100644 --- a/source/Components/AvalonDock/Controls/LayoutFloatingWindowControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutFloatingWindowControl.cs @@ -536,6 +536,26 @@ protected override void OnInitialized(EventArgs e) base.OnInitialized(e); } + protected override void OnClosing(CancelEventArgs e) + { + base.OnClosing(e); + AssureOwnerIsNotMinimized(); + } + + /// + /// Prevents a known bug in WPF, which wronlgy minimizes the parent window, when closing this control + /// + private void AssureOwnerIsNotMinimized() + { + try + { + Owner?.Activate(); + } + catch (Exception) + { + } + } + #endregion Overrides #region Private Methods