title: Change color of ListBoxItem background when selected and unfocused
body: <p>I am trying to change the background color of the selected items in a list box. I did that before by using</p>
  
  <pre><code>&lt;SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Yellow" /&gt;
  </code></pre>
  
  <p>which worked. But if I set IsEnabled to false on the ListBox, the whole background of the ListBox turns to the specified color of the ControlBrush. I only want to have the color changed if a ListBoxItem is selected and the ListBox has no focus.</p>
  
  <p>I tried some varieties with triggers, but I can't get it to work. Even a multitrigger containing conditions with IsSelected and IsFocused didn't work for me.</p>
  
  <p>Does anyone have a solution for me?</p>
  
  <p><strong>Edit:</strong>
  Tried the example with the ItemContainerStyle where I am getting a NullReferenceException in my project. In a new solution it works. That's the code where it doesn't work:</p>
  
  <pre><code>&lt;ItemsControl ItemsSource="{Binding Path=Classification.Values}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                   HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding Path=ClassificationEnabled}"
                                    VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Grid.Row="0" x:Name="measureClassificationControl"&gt;
                      &lt;ItemsControl.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Grid Margin="2"&gt;
                                  &lt;Grid.RowDefinitions&gt;
                                      &lt;RowDefinition Height="Auto"/&gt;
                                      &lt;RowDefinition Height="Auto"/&gt;
                                  &lt;/Grid.RowDefinitions&gt;
                                  &lt;TextBlock Text="{Binding Category}"/&gt;
                                  &lt;ListBox ItemsSource="{Binding Values.SortedList}" SelectionMode="Extended" Grid.Row="1"  AlternationCount="2" 
                                       SelectionChanged="ListBox_SelectionChanged" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Height="120"&gt;
                                      &lt;ListBox.ItemTemplate&gt;
                                          &lt;DataTemplate&gt;
                                              &lt;TextBlock TextWrapping="NoWrap" Text="{Binding Key}"&gt;
                                              &lt;TextBlock.ToolTip&gt;
                                                  &lt;ToolTip&gt;
                                                       &lt;TextBlock TextWrapping="NoWrap" Text="{Binding Value}"/&gt;
                                                  &lt;/ToolTip&gt;
                                              &lt;/TextBlock.ToolTip&gt;
                                          &lt;/TextBlock&gt;
                                          &lt;/DataTemplate&gt;
                                      &lt;/ListBox.ItemTemplate&gt;
                                  &lt;/ListBox&gt;
  
                              &lt;/Grid&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ItemsControl.ItemTemplate&gt;
                      &lt;ItemsControl.ItemsPanel&gt;
                          &lt;ItemsPanelTemplate&gt;
                              &lt;UniformGrid Columns="2"/&gt;
                          &lt;/ItemsPanelTemplate&gt;
                      &lt;/ItemsControl.ItemsPanel&gt;
                  &lt;/ItemsControl&gt;
  </code></pre>