diff --git a/MahApps.Metro/Controls/Dialogs/DialogManager.cs b/MahApps.Metro/Controls/Dialogs/DialogManager.cs index e839a533b0..dfbd84ebb2 100644 --- a/MahApps.Metro/Controls/Dialogs/DialogManager.cs +++ b/MahApps.Metro/Controls/Dialogs/DialogManager.cs @@ -362,6 +362,20 @@ public static Task HideMetroDialogAsync(this MetroWindow window, BaseMetroDialog })); }).Unwrap(); } + + //Get the current dialog of a MetroWindow + public static Task GetCurrentDialogAsync(this MetroWindow window) where TDialog : BaseMetroDialog + { + var t = new TaskCompletionSource(); + window.Dispatcher.Invoke((Action)(() => + { + TDialog dialog = null; + if (window.metroDialogContainer.Children.Count != 0) + dialog = window.metroDialogContainer.Children[0] as TDialog; + t.TrySetResult(dialog); + })); + return t.Task; + } private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) {