private void ActiveViews_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: ActiveViews.Add(e.NewItems[0].ToString()); break; case NotifyCollectionChangedAction.Remove: ActiveViews.Remove(e.OldItems[0].ToString()); break; case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Reset: ActiveViews.Clear(); foreach (var view in region.ActiveViews) { ActiveViews.Add(view.ToString()); } break; default: break; } RemoveActiveViewCommand.RaiseCanExecuteChanged(); SelectedViewName = ActiveViews.FirstOrDefault(); }
/// <summary> /// Marks the specified view as active. /// </summary> /// <param name="view">The view to activate.</param> /// <remarks>If there is an active view before calling this method, /// that view will be deactivated automatically.</remarks> public override void Activate(object view) { object currentActiveView = ActiveViews.FirstOrDefault(); if (currentActiveView != null && currentActiveView != view && this.Views.Contains(currentActiveView)) { base.Deactivate(currentActiveView); } base.Activate(view); }
/// <summary> /// Marks the specified view as active. /// </summary> /// <param name="view">The view to activate.</param> /// <remarks>If there is an active view before calling this method, /// that view will be deactivated automatically.</remarks> public override void Activate(VisualElement view) { var currentActiveView = ActiveViews.FirstOrDefault(); if (currentActiveView != null && currentActiveView != view && Views.Contains(currentActiveView)) { base.Deactivate(currentActiveView); } base.Activate(view); }