title: How to change the background of tabitem by using trigger in xaml?
body: <p><strong>Here is my Xaml code</strong></p>
  
  <pre><code>&lt;Window.Resources&gt;
          &lt;Style x:Key="SimpleTabControl" TargetType="{x:Type TabItem}"&gt;
              &lt;!--&lt;Setter Property = "TabStripPlacement" Value = "Top"/&gt;--&gt;
              &lt;Setter Property = "Background" Value= "Gray"/&gt;
              &lt;Setter Property="FontSize" Value="15"/&gt;
              &lt;Setter Property="Width" Value="200"/&gt;
              &lt;Setter Property="Height" Value="40"/&gt;
              &lt;Setter Property="HorizontalAlignment" Value="Left"/&gt;
              &lt;Setter Property="IsSelected" Value="False"/&gt;
              &lt;Setter Property="Margin" Value="3,0"/&gt;
              &lt;Style.Triggers&gt;
                  &lt;Trigger Property="TabItem.IsMouseOver" Value="true"&gt;
                      &lt;Setter Property="Background" Value="LightGreen"&gt;&lt;/Setter&gt;
                  &lt;/Trigger&gt;
              &lt;/Style.Triggers&gt;
  
          &lt;/Style&gt;
  
  
                  &lt;EventTrigger RoutedEvent="MouseEnter"&gt;
                      &lt;EventTrigger.Actions&gt;
  
                      &lt;/EventTrigger.Actions&gt;
                  &lt;/EventTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
          &lt;Style TargetType="{x:Type TabPanel}"&gt;
              &lt;Setter Property="Background" Value="LightGreen"&gt;&lt;/Setter&gt;
          &lt;/Style&gt;
  
      &lt;/Window.Resources&gt;
      &lt;Grid Background="White" Height="1000"  Width="auto" IsEnabled="True"&gt;
          &lt;TabControl Name="MainTab" Background="LightGray" SelectionChanged="MainTab_SelectionChanged"&gt;
              &lt;TabControl.Resources&gt;
                  &lt;Style TargetType="{x:Type TabPanel}"&gt;
                      &lt;Setter Property="HorizontalAlignment" Value="Left" /&gt;
                      &lt;Setter Property="Background" Value="White"/&gt;
                  &lt;/Style&gt;
              &lt;/TabControl.Resources&gt;
  
              &lt;TabItem Header="Input" x:Name="tabAlert1" Style="{StaticResource SimpleTabControl}" MouseEnter="TabItem_Enter" MouseLeave="TabItem_Leave" MouseDoubleClick="TabItem_Click" &gt;
  
                  &lt;!--&lt;TabItem.Header&gt;
                      &lt;Border Padding="0,0"&gt;
                          &lt;StackPanel Orientation="Horizontal"  Background="Gray" HorizontalAlignment="Left" Width="200" Height="40" Margin="0,0"&gt;
                              &lt;TextBlock Text="Input" Foreground="White" FontSize="15" TextAlignment="Right"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/Border&gt;
  
                  &lt;/TabItem.Header&gt;--&gt;
                  &lt;Label Content="Content goes here..." /&gt;
              &lt;/TabItem&gt;
              &lt;TabItem Header="Analysis" x:Name="tabAlert2"  Style="{StaticResource SimpleTabControl}" /&gt;
              &lt;TabItem Header="Action???" x:Name="tabAlert3" Style="{StaticResource SimpleTabControl}"/&gt;
          &lt;/TabControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I don't know for some reason the  trigger for isMouseOver is not triggering the back ground color change Change for Tab Item.</p>
  
  <p>I have also tried the c# , code behind way , but with no success, but if change the foreground  property, it works, but not he Background property.</p>
  
  <p><strong>Here is my C# Way</strong></p>
  
  <pre><code>private void TabItem_Enter(object sender, System.Windows.Input.MouseEventArgs e)
      {
          //var tabItem = sender as TabItem;
          //tabAlert2.Background = Brushes.Red;
          //tabItem.Background = Brushes.Green;
          var tabItem = sender as TabItem;
          tabItem.Background = new SolidColorBrush(Colors.Gray);
  
      }
  </code></pre>
  
  <p>I have Bound the mouse enter  event to tab Item.this is very basic but am frustrated this not working?Any help much appreciated. </p>