Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the dialog from a MetroWindow #1467

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions MahApps.Metro/Controls/Dialogs/DialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,20 @@ public static Task HideMetroDialogAsync(this MetroWindow window, BaseMetroDialog
}));
}).Unwrap();
}

//Get the current dialog of a MetroWindow
public static Task<TDialog> GetCurrentDialogAsync<TDialog>(this MetroWindow window) where TDialog : BaseMetroDialog
{
var t = new TaskCompletionSource<TDialog>();
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)
{
Expand Down