title: WPF TreeViewItem Background
body: <p>How can I change the <code>Background</code> of a selected <code>TreeViewItem</code> when the <code>TreeView</code> (or the Application) looses Focus. A selected item by default has in this situation a light grey background.</p>
  
  <p>EDIT: A try after first answer: But element with <code>TargetName="Bd"</code> will not be found.</p>
  
  <pre><code>&lt;TreeView&gt;
          &lt;TreeView.Resources&gt;
              &lt;Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"&gt;
                  &lt;Setter Property="Template"&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate TargetType="{x:Type TreeViewItem}"&gt;
                              &lt;ControlTemplate.Triggers&gt;
                                  &lt;MultiTrigger&gt;
                                      &lt;MultiTrigger.Conditions&gt;
                                          &lt;Condition Property="IsSelected" Value="True"/&gt;
                                          &lt;Condition Property="IsSelectionActive" Value="False"/&gt;
                                      &lt;/MultiTrigger.Conditions&gt;
                                      &lt;Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" /&gt;
                                      &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /&gt;
                                  &lt;/MultiTrigger&gt;
                              &lt;/ControlTemplate.Triggers&gt;
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
              &lt;/Style&gt;
          &lt;/TreeView.Resources&gt;
  
          &lt;TreeViewItem Header="Test1" IsExpanded="True"&gt;
              &lt;TreeViewItem Header="Test2" /&gt;
              &lt;TreeViewItem Header="Test3" /&gt;
              &lt;TreeViewItem Header="Test4" /&gt;
              &lt;TreeViewItem Header="Test5" /&gt;
          &lt;/TreeViewItem&gt;
      &lt;/TreeView&gt;
  </code></pre>