/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter != null && e.PageState == null) { long noteID = (long)e.NavigationParameter; viewModel = new EditPhotoNoteViewModel((PhotoNote)photoNoteManager.GetNoteById(noteID)); Debug.WriteLine(viewModel.ToString()); action = PageAction.Update; if (viewModel.IsNotificationDateVisible) { SetNotificationSchedulingVisibile(true); } } else { if (e.PageState != null) { EditPhotoNoteViewModel editPhotoNoteViewModel = (EditPhotoNoteViewModel)e.PageState[VIEW_MODEL]; if (editPhotoNoteViewModel != null) { viewModel = editPhotoNoteViewModel; e.PageState[VIEW_MODEL] = null; } if (e.NavigationParameter != null) { action = PageAction.Update; } else { action = PageAction.Create; } } else { viewModel = new EditPhotoNoteViewModel(); } } ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; Object value = localSettings.Values[PhotoNoteManager.PHOTO_PATH_KEY]; if (value != null) { Debug.WriteLine(value); viewModel.PhotoPath = (string)value; localSettings.Values.Remove(PhotoNoteManager.PHOTO_PATH_KEY); } this.DataContext = viewModel; }
/// <summary> /// Gets the view model for this <see cref="Page"/>. /// This can be changed to a strongly typed view model. /// </summary> //public ObservableDictionary DefaultViewModel //{ // get { return this.defaultViewModel; } //} /// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter != null) { long noteID = (long)e.NavigationParameter; viewModel = new EditSimpleNoteDetailViewModel((SimpleNote)simpleNoteManager.GetNoteById(noteID)); Debug.WriteLine(viewModel.ToString()); action = PageAction.Update; if(viewModel.IsNotificationDateVisible){ SetNotificationSchedulingVisibile(true); } } else { viewModel = new EditSimpleNoteDetailViewModel(); } this.DataContext = viewModel; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter != null) { long noteID = (long)e.NavigationParameter; viewModel = new EditTodoNoteViewModel((TodoNote)todoNoteDataHelper.GetNoteById(noteID)); if (viewModel.IsNotificationDateVisible) { SetNotificationSchedulingVisibile(true); } state = PageAction.Update; } else { viewModel = new EditTodoNoteViewModel(); viewModel.AddEntry(EMPTY_STRING, false); state = PageAction.Create; } this.DataContext = viewModel; TodoNotesList.DataContext = viewModel.TodoEntries; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/>. /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { FirstPivot_Loaded(sender, new RoutedEventArgs()); }