/// <summary> /// Whenever the View is unloaded, we want to cancel any edit operation /// that is in progress. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserControl_Unloaded(object sender, RoutedEventArgs e) { logger.Debug("UserControl unloading."); if (IsInPeopleEditMode) { logger.Debug("IsInPeopleEditMode is true during unload. Canceling edit."); ((IEditableCollectionView)_peopleView).CancelEdit(); PeopleDataGrid.CancelEdit(); IsInPeopleEditMode = false; } if (IsInFamilyEditMode) { logger.Debug("IsInFamilyEditMode is true during unload. Canceling edit."); ((IEditableCollectionView)_familyView).CancelEdit(); FamilyDataGrid.CancelEdit(); IsInFamilyEditMode = false; } }
/// <summary> /// The constructor for the ClassesView. Wires up all the necessary /// objects and events needed by this View. /// </summary> /// <param name="presenter"></param> /// <param name="eventAggregator"></param> /// <param name="configurationService"></param> public PersonsView(PersonsPresenter presenter, IEventAggregator eventAggregator, IConfigurationService configurationService) : this() { _presenter = presenter; _presenter.View = this; _eventAggregator = eventAggregator; _configurationService = configurationService; logger.Debug("Subscribing to ShellRefreshRequestedEvent."); ShellRefreshRequestedEvent shellRefreshRequestedEvent = _eventAggregator.GetEvent <ShellRefreshRequestedEvent>(); shellRefreshRequestedEvent.Subscribe(OnShellRefreshRequested, ThreadOption.UIThread); // Hook into the CanExecuteEvent of the DataGrid so that we can look for // when user tries to Delete PeopleDataGrid.AddHandler(CommandManager.CanExecuteEvent, new CanExecuteRoutedEventHandler(OnCanExecuteRoutedEventHandler), true); // Hook into the CanExecuteEvent of the DataGrid so that we can look for // when user tries to Delete FamilyDataGrid.AddHandler(CommandManager.CanExecuteEvent, new CanExecuteRoutedEventHandler(OnCanExecuteRoutedEventHandler), true); }