public void SaveResult() { dialogBuilder.Reset(); var confirmationAction = new System.Action(async() => { var errorString = dialogBuilder.UnderlyingViewModel.Error; if (!string.IsNullOrEmpty(errorString)) { MessageBox.Show(errorString, "Validation error", MessageBoxButton.OK); } else { var description = dialogBuilder.UnderlyingViewModel.Description; PlotViewModel.Description = description; await PlotViewModel.UpdateAndSaveAsync(); } }); dialogBuilder.Title("Enter description") .LeftButtonContent("OK") .RightButtonContent("Cancel") .LeftButtonAction(confirmationAction); dialogBuilder.Show(); }
public void AddNewItem() { dialogBuilder.Reset(); var confirmationAction = new Action(() => { var errorString = dialogBuilder.UnderlyingViewModel.Error; if (!string.IsNullOrEmpty(errorString)) { MessageBox.Show(errorString, "Validation error", MessageBoxButton.OK); } else { var newItem = dialogBuilder.UnderlyingViewModel.ToPresetItem(); var existingItem = PresetItems.SingleOrDefault( x => x.Frequency == newItem.Frequency); if (existingItem != null) { PresetItems.Remove(existingItem); } PresetItems.Add(newItem); var items = PresetItems.OrderBy(x => x.Frequency).ToList(); PresetItems.Clear(); PresetItems.AddRange(items); } }); dialogBuilder.Title("Add item...") .LeftButtonContent("OK") .RightButtonContent("Cancel") .LeftButtonAction(confirmationAction) .Show(); }