title: Set an image when a tabitem is selected
body: <p>I am new with the wpf and I cannot figure out how should I set an image when a tab item is selected.</p>
  
  <p>I write a style but it doesnt work. It shows me anything...</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Style TargetType="TabItem"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="TabItem"&gt;
                  &lt;Grid&gt;
                     &lt;StackPanel Orientation="Horizontal"&gt;
                         &lt;HeaderedItemsControl Name="img"  &gt;
                         &lt;/HeaderedItemsControl&gt;
                     &lt;/StackPanel&gt;
                  &lt;/Grid&gt;
               &lt;ControlTemplate.Triggers&gt;
               &lt;Trigger Property="IsSelected" Value="True"&gt;
                     &lt;Setter Property="Visibility" TargetName="img" Value="Visible"/&gt;    
               &lt;/Trigger&gt;      
               &lt;Trigger Property="IsSelected" Value="False"&gt;
                     &lt;Setter Property="Visibility" TargetName="img" Value="Hidden"/&gt;
               &lt;/Trigger&gt;
           &lt;/ControlTemplate.Triggers&gt;      
         &lt;/ControlTemplate&gt;     
       &lt;/Setter.Value&gt;      
     &lt;/Setter&gt;     
   &lt;/Style&gt;     
  </code></pre>
  
  <p>For the tab control I wrote the code:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;TabControl Name="tabControl1"  
               HorizontalAlignment="Left"                  
               VerticalAlignment="Top" 
               Height="311" 
               Width="503"&gt;
      &lt;TabItem Name="tabItem1" Background="Red"  &gt;                
              &lt;TabItem.Header&gt;
                  &lt;Grid&gt;
                      &lt;TextBlock Text="   First" Width="100" Margin="-2,33,4,16" /&gt;
                      &lt;Image  Name="img" Source="menu.png" Height="20" Margin="0,60,0,0" /&gt;
                  &lt;/Grid&gt;
  
              &lt;/TabItem.Header&gt;
              &lt;Grid&gt;
  
              &lt;TextBox Name="denumire" Margin="31,20,169,67" Height="20" Width="60"/&gt;
              &lt;/Grid&gt;
  
          &lt;/TabItem&gt;
      &lt;TabItem Name="tabItem2" Header="tabItem2" Background="Red"&gt;
          &lt;/TabItem&gt;
      &lt;/TabControl&gt;
  </code></pre>