public async Task <T> ShowDialogAsync <T>(DialogScreen <T> dialogScreen) where T : class { // Show the dialog await ShowDialogAsync((DialogScreen)dialogScreen); // use the return-less overload // Return the result return(dialogScreen.DialogResult); }
public async Task ShowDialogAsync(DialogScreen dialogScreen) { // Get the view that renders this viewmodel var view = _viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen); // Set up event routing that will close the view when called from viewmodel DialogOpenedEventHandler onDialogOpened = (sender, e) => { // Delegate to close the dialog and unregister event handler void OnScreenClosed(object o, CloseEventArgs args) { e.Session.Close(); dialogScreen.Closed -= OnScreenClosed; } dialogScreen.Closed += OnScreenClosed; }; // Show view await DialogHost.Show(view, onDialogOpened); }
public async Task <T> ShowDialogAsync <T>(DialogScreen <T> dialogScreen) { // Get the view that renders this viewmodel var view = _viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen); // Set up event routing that will close the view when called from viewmodel void OnDialogOpened(object openSender, DialogOpenedEventArgs openArgs) { // Delegate to close the dialog and unregister event handler void OnScreenClosed(object closeSender, CloseEventArgs closeArgs) { openArgs.Session.Close(); dialogScreen.Closed -= OnScreenClosed; } dialogScreen.Closed += OnScreenClosed; } // Show view await DialogHost.Show(view, OnDialogOpened); // Return the result return(dialogScreen.DialogResult); }