I did not receive the selected answer for work, maybe something has changed, maybe my setting is different.
My solutions are simple, you send the sender to tabControle. Then you pull out the selected TabItem (selectedValue) and pass it to the TabItem.
In my situation, I need to know who has changed, so I'm looking for the name TabItem to better respond to a specific event.
Xaml
<TabControl SelectionChanged="OnTabItemChanged"> <TabItem Name="MainTap" Header="Dashboard"></TabItem </TabControl>
FROM#
private async void OnTabItemChanged(object sender, SelectionChangedEventArgs e) { TabControl tabControl = sender as TabControl; // e.Source could have been used instead of sender as well TabItem item = tabControl.SelectedValue as TabItem; if (item.Name == "MainTap") { Debug.WriteLine(item.Name); } }
Christopher bonitz
source share