private void ClearThePage() { NewExIntensityListPicker.ClearValue(ListPicker.DataContextProperty); _viewModel.ValidationError -= _viewModel_ValidationError; _viewModel = null; }
public ExercisePage() { Device.SetFlags(new[] { "CollectionView_Experimental", "Shell_Experimental" }); InitializeComponent(); BindingContext = new ExercisePageViewModel(); }
private void CheckIfEditOrAddActionRequiredAsync() { string action; if (NavigationContext.QueryString.TryGetValue("action", out action)) { if (action == "edit") { string exIdStr; int exId; if (NavigationContext.QueryString.TryGetValue("exId", out exIdStr) && Int32.TryParse(exIdStr, out exId)) { Exercise exToEdit = App.FitAndGymViewModel.GetExerciseById(exId); if (exToEdit != null) _viewModel = new ExercisePageViewModel(exToEdit); else throw new Exception(String.Format("Not found Exercise with id = {0} in database invoked from ExercisePage!", exId)); } else throw new Exception("Wrong NavigationContext.QueryString 'exId' in ExercisePage"); } else if (action == "add") _viewModel = new ExercisePageViewModel(); else throw new Exception(String.Format("Wrong NavigationContext.QueryString (action) in ExercisePage. Action = '{0}'", action)); _viewModel.ValidationError += _viewModel_ValidationError; DataContext = _viewModel; } }