Although this question is quite old and already answered well, I thought I'd add this additional answer to demonstrate an alternative way to change the selected TabItem in TabControl . If you have a presentation model for each TabItem , then it may be useful to have the IsSelected property in it to determine if it is selected or not. This can be associated with this IsSelected property IsSelected property using the TabItem.IsSelected property:
<TabControl ItemsSource="{Binding MenuItems}" TabStripPlacement="Top"> <TabControl.ItemTemplate> <DataTemplate DataType="{x:Type ControlViewModels:MenuItemViewModel}"> <StackPanel Orientation="Horizontal"> <Image Source="{Binding ImageSource}" Margin="0,0,10,0" /> <TextBlock Text="{Binding HeaderText}" FontSize="16" /> </StackPanel> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate DataType="{x:Type ControlViewModels:MenuItemViewModel}"> <ContentControl Content="{Binding ViewModel}" /> </DataTemplate> </TabControl.ContentTemplate> <TabControl.ItemContainerStyle> <Style TargetType="{x:Type TabItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected}" /> </Style> </TabControl.ItemContainerStyle> </TabControl>
Now you can change the selected TabItem from the parent view model as follows:
MenuItems[0].IsSelected = true;
Note that since this property is data bound to the TabItem.IsSelected property, calling this ...:
MenuItems[1].IsSelected = true;
... infact also automatically sets the MenuItems[0].IsSelected to false . therefore, if the view model you are working with has the IsSelected property set to true, then you can be sure that its associated view is selected in TabControl .
Sheridan
source share