/// <summary> /// Constructor for Edit Form /// </summary> public EditForm() { InitializeComponent(); viewModel = App.MainViewModel.SelectedItemEditViewModelInstance; if (!viewModel.IsInitialized) { viewModel.InitializationCompleted += new EventHandler <InitializationCompletedEventArgs>(OnViewModelInitialization); viewModel.Initialize(); } else { this.DataContext = viewModel; } }
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); }