public async Task ShowPopup(IViewModel contents) { await ClosePopup(); _currentPopup = new PopupWindow(_navigator) { DataContext = contents }; EventHandler windowClosed = null; windowClosed = (sender, args) => { FocusMainWindow(); _currentPopup.Closed -= windowClosed; }; _currentPopup.Closed += windowClosed; UnfocusMainWindow(); _currentPopup.ShowModal(_mainWindow, _appHost.UserInputManager); }
public async Task ClosePopup() { if (_currentPopup != null) { var context = _currentPopup.DataContext as IViewModel; if (context != null) { await context.Close(); } _currentPopup.Close(); _currentPopup = null; } }