public StandardWindowInstance(BaseIconWindow window) { _window = window ?? throw new ArgumentNullException(nameof(window)); Window.Closing += Window_Closing; Window.Closed += Window_Closed; }
protected virtual async Task ShowAsync(IWindowControl windowContent, bool isModal, string title) { // Create the window var window = new BaseIconWindow(); // Configure the window ConfigureWindow(window, windowContent); // Set the window instance windowContent.WindowInstance = new StandardWindowInstance(window); // Set the title if (title != null) { windowContent.WindowInstance.Title = title; } if (isModal) { // Show the window as a dialog window.ShowDialog(); } else { var tcs = new TaskCompletionSource <object>(); void Window_Closed(object sender, EventArgs e) { window.Closed -= Window_Closed; tcs.TrySetResult(null); } window.Closed += Window_Closed; // Show the window window.Show(); // Wait for the window to close await tcs.Task; } }