private void AddButton_OnClick(object sender, RoutedEventArgs e) { var AddDialog = new AddTaskDialog(); if (AddDialog.ShowDialog() != true) { return; } var planReturned = AddDialog.Value as Plan; if (planReturned == null) { return; } planReturned.State = PlanState.ToDo; (this.DataContext as IPresentation)?.AddPlan(planReturned); }
private void EditMenuItem_OnClick(object sender, RoutedEventArgs e) { var menuItem = (MenuItem)e.Source; var contextMenu = (ContextMenu)menuItem.Parent; var items = (ListView)contextMenu.PlacementTarget; var toEditPlan = items.SelectedItem as Plan; if (toEditPlan == null) { return; } var backupPlan = toEditPlan.DeepClone(); var AddDialog = new AddTaskDialog(toEditPlan); if (AddDialog.ShowDialog() != true) { toEditPlan = backupPlan.DeepClone(); } }