private void OnItemUpdated(object sender, ItemUpdatedEventArgs e) { this.Dispatcher.BeginInvoke(() => { if (e.Error != null) { MessageBox.Show(e.Error.Message, e.Error.GetType().Name, MessageBoxButton.OK); return; } // Remove Draft Item from local storage if update to server is successful. DraftItemStore.RemoveDraftItem(viewModel.ID.ToString()); this.NavigationService.Navigate(new Uri("/Views/List.xaml", UriKind.Relative)); }); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // Include initialization of ViewModel here rather than in constructor to be able to use QueryString value. if (viewModel == null) { viewModel = DraftItemStore.GetDraftItemById(NavigationContext.QueryString["ID"].ToString()); } this.DataContext = viewModel; viewModel.InitializationCompleted += new EventHandler <InitializationCompletedEventArgs>(OnViewModelInitialization); viewModel.ItemUpdated += new EventHandler <ItemUpdatedEventArgs>(OnItemUpdated); viewModel.Initialize(); base.OnNavigatedTo(e); }
public void SaveAsDraft() { DraftItemStore.AddDraftItem(this.ID.ToString(), this); }