/// <summary> /// Display a Save before Closing dialog /// </summary> /// <returns>Returns UnsavedDialogResult</returns> private async Task <UnsavedDialogResult> SaveBeforeClosing() { UnsavedDialog dialog = new UnsavedDialog(); await dialog.ShowAsync(); var answer = dialog.Result; return(answer); }
public void UnsavedChangesExit() { CancelFormExit = false; UnsavedDialog unsavedDialog = new UnsavedDialog(); unsavedDialog.Disposed += unsavedDialog_Disposed; // If there are unsaved changes, show a confirmation dialog and // handle the result accordingly. if (unsavedChanges == true) { switch (unsavedDialog.ShowDialog()) { // Save work before closing. case DialogResult.OK: CancelFormExit = false; Save(true); break; // Close without saving. case DialogResult.No: CancelFormExit = false; break; // Keep the application open. case DialogResult.Cancel: CancelFormExit = true; break; } unsavedDialog.Dispose(); } else { // If all changes are saved, just close the program // without confirmation. Application.Exit(); } }
private async void ShowUnsavedDialog() { UnsavedDialog dialog = new UnsavedDialog(); await dialog.ShowAsync(); }