title: WPF ListBox ErrorTemplate
body: <p>In my WPF application I've a ListBox binding to a collection of view models.
  Those view models support validation by implement INotifyDataErrorInfo.
  I’m trying to display an error template for items with validation errors in my ListBox. </p>
  
  <p>I’m able to get the ListBox to display the default error template by setting <em>NotifyOnValidationError=True</em> on the ItemSource binding of the ListBox.<br/>
  Which looks like this:
  <a href="https://i.stack.imgur.com/AVULN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AVULN.png" alt="enter image description here"></a></p>
  
  <p>Code of my ListBox:</p>
  
  <pre><code>&lt;ListBox x:Name="ListBoxEvents" ItemsSource="{Binding Events, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" 
                   IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource EventListTemplate}"&gt;&lt;/ListBox&gt;
  </code></pre>
  
  <p>My ListBox style:</p>
  
  <pre><code>&lt;ControlTemplate x:Key="ListBoxValidationError"&gt;
      &lt;DockPanel LastChildFill="True"&gt;
          &lt;Border Background="Red" Margin="5"&gt;
              &lt;AdornedElementPlaceholder /&gt;
          &lt;/Border&gt;
      &lt;/DockPanel&gt;
  &lt;/ControlTemplate&gt;
  
  &lt;Style TargetType="{x:Type ListBox}"&gt;
      &lt;Setter Property="BorderBrush" Value="{StaticResource WindowTitleBrush}" /&gt;
      &lt;Setter Property="BorderThickness" Value="1" /&gt;
      &lt;Setter Property="MinWidth" Value="200" /&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"&gt;&lt;/Setter&gt;
      &lt;Setter Property="ScrollViewer.CanContentScroll" Value="False"&gt;&lt;/Setter&gt;
      &lt;Setter Property="Validation.ErrorTemplate" Value="{StaticResource ListBoxValidationError}"&gt;&lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The ListBox item template:</p>
  
  <pre><code>&lt;DataTemplate x:Key="EventListTemplate" DataType="{x:Type event:EventViewModel}"&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="Auto" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto" /&gt;
              &lt;RowDefinition Height="Auto" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
         &lt;TextBlock Text="{Binding Title, Converter={StaticResource EmptyStringConverter}, ConverterParameter='-'}" FontWeight="Bold" FontSize="14" /&gt;
          &lt;TextBlock Text="{Binding Date, StringFormat={}{0:dd.MM.yyyy}}" Grid.Row="1" Grid.Column="0" FontStyle="Italic" /&gt;
          &lt;Button Grid.Column="1" Grid.RowSpan="2" Grid.Row="0" Style="{DynamicResource ItemDeleteButton}" /&gt;
      &lt;/Grid&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>How can I display a custom error template for my ListBoxItems?
  (My goal is to make the background of the items red)</p>