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 async void BackKeyPress() { if (string.IsNullOrEmpty(PlotViewModel.Description)) { await PlotViewModel.DeleteAll(); } }
public ResultsPageViewModel(INavigationService navigationService, IDialogBuilder <SaveResultView, SaveResultViewModel> builder, PlotViewModel plotViewModel, DataViewModel dataViewModel) { this.navigationService = navigationService; PlotViewModel = plotViewModel; DataViewModel = dataViewModel; dialogBuilder = builder; }
private async Task <bool> Discard() { if (string.IsNullOrEmpty(PlotViewModel.Description)) { var result = MessageBox.Show("Are you sure you want to discard the result?", "Confirmation", MessageBoxButton.OKCancel); if (result != MessageBoxResult.OK) { return(false); } await PlotViewModel.DeleteAll(); return(true); } return(true); }