WPF Tab Control: How do I get the currently selected tab? WPF Tab Control: How do I get the currently selected tab? wpf wpf

WPF Tab Control: How do I get the currently selected tab?


TabControl.SelectedItem is the selected tab.

cast it to a TabItem to get the properties.

What I mostly do is bind it to a viewmodel.


you can use the TabControl.SelectedItem property, it will get you the selected TabItem

Sample shown below

TabItem ti = Tabs1.SelectedItem as TabItem;MessageBox.Show("This is " + ti.Header + " tab");


TabControl.SelectedIndex gets you the currently selected tab index in version 3.0 and later of the .NET Framework.