Detecting when a tab item has been added to WPF Tab control

I am trying to synchronize a selected tab of a WPF tab control with the last item added.

Since there is no such property as, for example, IsSynchedWithLastAddedItem, I am trying to detect when an element was added to indicate SelectedItem on the last added one.

I cannot find the event that is being raised - either in the tab control or in its elements when TabItem was added.

I am sure something like this should exist, although I hope someone can help me.

+5
source share
2 answers
var view=CollectionViewSource.GetDefaultView(m_tabControl.ItemsSource);
view.CollectionChanged+=(o,e)=>{/*Here your code*/};

Items, . CollectionViewSource .

var view=CollectionViewSource.GetDefaultView(m_tabControl.Items);
view.CollectionChanged+=(o,e)=>{/*Here your code*/};

Timores , m_tabControl.Items, . ItemsSource-, INotifyCollectionChanged.

. , .

+9

Items ItemCollection, CollectionView, INotifyCollectionChanged. , CollectionChanged , .

, XAML.

0

All Articles