WPF TabItem Header Header

I have a TabControl in WPF with 3 tabs, and each tab has an image next to the name of the tab. Here is an example

        <TabItem>
            <TabItem.Header>
                <StackPanel Orientation="Horizontal">
                    <Image Name="img" Height="auto" Width="auto" Source="images/1.png" />
                    <TextBlock Text="Login" Margin="2,0,0,0" VerticalAlignment="Center" />
                </StackPanel>
            </TabItem.Header>
        </TabItem>

When a tab is selected, the text is black and the background is white when it is not a light gray color and a bit darker text. This works fine, but I can't figure out how to change images on tabs that are not selected? Right now the images look the same, the green circle with the number inside, but when the tab is not selected, I would like it to change to another image, that is, the images /1_notselected.png and images / 2_notselected.png when the tab is selected. Thanks!

+5
source share
1 answer

TabItem, .

HeaderTemplate, Trigger :

   <Trigger Property="IsSelected" Value="True">
       <Setter Property="Source" TargetName="img" Value="images/customimage.png"/>
   </Trigger>
+6

All Articles