From f5c2676dd5483fc81c1803e6053ba8f929086ad8 Mon Sep 17 00:00:00 2001 From: punker76 Date: Mon, 3 Oct 2022 23:14:01 +0200 Subject: [PATCH] feat: #68 open child window on controls and not only window --- .../ChildWindowManager.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/MahApps.Metro.SimpleChildWindow/ChildWindowManager.cs b/src/MahApps.Metro.SimpleChildWindow/ChildWindowManager.cs index ca19da1..44d31de 100644 --- a/src/MahApps.Metro.SimpleChildWindow/ChildWindowManager.cs +++ b/src/MahApps.Metro.SimpleChildWindow/ChildWindowManager.cs @@ -30,7 +30,7 @@ public enum OverlayFillBehavior /// /// Shows the given child window on the MetroWindow dialog container in an asynchronous way. /// - /// The owning window with a container of the child window. + /// The owning control with a container for the child window. /// A child window instance. /// The overlay fill behavior. /// @@ -41,16 +41,16 @@ public enum OverlayFillBehavior /// or /// The provided child window is already visible in the specified window. /// - public static Task ShowChildWindowAsync(this Window window, ChildWindow dialog, OverlayFillBehavior overlayFillBehavior = OverlayFillBehavior.WindowContent) + public static Task ShowChildWindowAsync(this Control control, ChildWindow dialog, OverlayFillBehavior overlayFillBehavior = OverlayFillBehavior.WindowContent) { - return window.ShowChildWindowAsync(dialog, overlayFillBehavior); + return control.ShowChildWindowAsync(dialog, overlayFillBehavior); } /// /// Shows the given child window on the MetroWindow dialog container in an asynchronous way. /// When the dialog was closed it returns a result. /// - /// The owning window with a container of the child window. + /// The owning control with a container for the child window. /// A child window instance. /// The overlay fill behavior. /// @@ -61,14 +61,14 @@ public static Task ShowChildWindowAsync(this Window window, ChildWindow dialog, /// or /// The provided child window is already visible in the specified window. /// - public static async Task ShowChildWindowAsync(this Window window, ChildWindow dialog, OverlayFillBehavior overlayFillBehavior = OverlayFillBehavior.WindowContent) + public static async Task ShowChildWindowAsync(this Control control, ChildWindow dialog, OverlayFillBehavior overlayFillBehavior = OverlayFillBehavior.WindowContent) { var tcs = new TaskCompletionSource(); - window.Dispatcher.VerifyAccess(); + control.Dispatcher.VerifyAccess(); - var metroDialogContainer = window.Template.FindName("PART_MetroActiveDialogContainer", window) as Grid; - metroDialogContainer = metroDialogContainer ?? window.Template.FindName("PART_MetroInactiveDialogsContainer", window) as Grid; + var metroDialogContainer = control.Template.FindName("PART_MetroActiveDialogContainer", control) as Grid; + metroDialogContainer = metroDialogContainer ?? control.Template.FindName("PART_MetroInactiveDialogsContainer", control) as Grid; if (metroDialogContainer == null) { throw new InvalidOperationException("The provided child window can not add, there is no container defined."); @@ -92,7 +92,7 @@ public static async Task ShowChildWindowAsync(this Window wind /// Shows the given child window on the given container in an asynchronous way. /// When the dialog was closed it returns a result. /// - /// The owning window with a container of the child window. + /// The owning control with a container for the child window. /// A child window instance. /// The container. /// @@ -101,15 +101,15 @@ public static async Task ShowChildWindowAsync(this Window wind /// or /// The provided child window is already visible in the specified window. /// - public static Task ShowChildWindowAsync(this Window window, ChildWindow dialog, Panel container) + public static Task ShowChildWindowAsync(this Control control, ChildWindow dialog, Panel container) { - return window.ShowChildWindowAsync(dialog, container); + return control.ShowChildWindowAsync(dialog, container); } /// /// Shows the given child window on the given container in an asynchronous way. /// - /// The owning window with a container of the child window. + /// The owning control with a container for the child window. /// A child window instance. /// The container. /// @@ -118,11 +118,11 @@ public static Task ShowChildWindowAsync(this Window window, ChildWindow dialog, /// or /// The provided child window is already visible in the specified window. /// - public static async Task ShowChildWindowAsync(this Window window, ChildWindow dialog, Panel container) + public static async Task ShowChildWindowAsync(this Control control, ChildWindow dialog, Panel container) { var tcs = new TaskCompletionSource(); - window.Dispatcher.VerifyAccess(); + control.Dispatcher.VerifyAccess(); if (container == null) {