How to programmatically select a TabItem in WPF TabControl

Solution 1:

As @Chris says, any of the first three things should work and as @Phyxx says, it doesn't always really work. The problem is some subtle thing about the order of property changes. To work around it you need to let the WPF invoke your tab-selection code in its own time:

Dispatcher.BeginInvoke((Action)(() => MyTabControl.SelectedIndex = x));

This does just what Phyxx' timer does, but in a slightly less extreme way.

Solution 2:

All your examples except the third one are correct and will work. The problem must be at another location. Maybe you reset the item after setting or your code never is called?

Valid

MyTabControl.SelectedIndex = x   
MyTabControl.SelectedItem = MyTabItem    
MyTabItem.IsSelected = True 

Invalid

MyTabControl.SelectedValue = MyTabItem