protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) { collectionChanging = true; base.OnItemsChanged(e); collectionChanging = false; if ((e.NewItems != null) && (e.NewItems.Count > 0)) { TabView view = (TabView)e.NewItems[0]; this.SelectedItem = view; if (!view.IsLoaded) { RoutedEventHandler loaded = null; loaded = (sender, ea) => { view.Loaded -= loaded; this.InvalidateMeasure(); }; view.Loaded += loaded; } } this.InvalidateMeasure(); //base.OnItemsChanged(e); }
private static void IsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TabView owner = (TabView)d; bool value = (bool)e.NewValue; // We only update the parent window too, if we are in tab. //if (value && owner.IsRegularTab && (owner.ParentWindow != null)) // owner.ParentWindow.SelectedView = owner; }