private async void btnDelete_Click(object sender, RoutedEventArgs e) { //checks for notes, and gets confirmation from the user if ((lsvNoteList.SelectedIndex != -1) && await ConfirmMessageBoxAsync("Delete this Note")) { Debug.WriteLine("Note Deleted"); apbNoteName.Text = DeselectedTitleValue; //txtNoteBody.Text = DeselectedBodyValue; rebNoteBody.Document.SetText(Windows.UI.Text.TextSetOptions.None, DeselectedBodyValue); MainPageData.DeleteNote(); btnDelete.IsEnabled = false; btnEditNote.IsEnabled = false; } else { btnDelete.IsEnabled = true; //handles canceled delete Debug.WriteLine("Note not Deleted"); } }
private async void DeleteNote(object sender, RoutedEventArgs e) { var title = "Delete Note"; var content = "Are you sure you would like to Delete the current note?"; var Delete = new UICommand("Yes"); var Nothing = new UICommand("No"); var dialog = new MessageDialog(content, title); dialog.Options = MessageDialogOptions.None; dialog.Commands.Add(Delete); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 0; if (Nothing != null) { dialog.Commands.Add(Nothing); dialog.CancelCommandIndex = (uint)dialog.Commands.Count - 1; } var command = await dialog.ShowAsync(); if (command == Delete) { MainPageData.DeleteNote(); } else if (command == Nothing) { // handle no command } else { // handle cancel command } Debug.WriteLine("Delete Note"); }