public async override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary<string, object> viewModelState) {
            base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState);

            if (viewModelState != null) {
                if (navigationMode == NavigationMode.Refresh) {
                    var stateErrorsCollection = RetrieveEntityStateValue<IDictionary<string, ReadOnlyCollection<string>>>("stateErrorsCollection", viewModelState);
                    if (stateErrorsCollection != null) {
                        SelectedState.SetAllErrors(stateErrorsCollection);
                    }
                }
            }

            // Note: Each time app selects from main page (StateListPage) detail page (StateDetailPage) is recreated.
            // Meaning that constructor is run and SelectedState is null.
            // If SuspendAndTerminate (e.g. debug mode) SelectedState is saved to SessionState (because of [RestorableState] attribute).
            // Therefore, if SelectedState has been saved, use it instead of doing GetStateAsync.
            if (SelectedState == null) {
                string errorMessage = string.Empty;
                int stateId = (int)navigationParameter;

                if (stateId == 0) {
                    SelectedState = new State();
                    SelectedState.ValidateProperties();
                    RunAllCanExecute();
                }
                else {
                    try {
                        LoadingData = true;
                        CrudResult = await _stateRepository.GetStateAsync(stateId);
                        SelectedState = JsonConvert.DeserializeObject<List<State>>(CrudResult.Content.ToString()).FirstOrDefault<State>();
                    }
                    catch (HttpRequestException ex) {
                        ErrorMessageTitle = ErrorMessagesHelper.HttpRequestExceptionError;
                        //TODO: Log stack trace to database here
                        ErrorMessage = string.Format("{0}", ex.Message);
                    }
                    finally {
                        LoadingData = false;
                    }
                    if (ErrorMessage != null && ErrorMessage != string.Empty) {
                        MessageDialog messageDialog = new MessageDialog(ErrorMessage, ErrorMessageTitle);
                        await messageDialog.ShowAsync();
                        _navService.GoBack();
                    }
                }
            }

            RunAllCanExecute();
        }
 // When New button is pressed
 private void OnNewState() {
     SelectedState = new State();
     SelectedState.ValidateProperties();
     RunAllCanExecute();
 }