title: ListView losing GridView display when applying ItemContainerStyle
body: <p>I have a WPF application in which I styled several components to look more like the default Windows 7 style. Now I wanted to do the same for a ListView, since the default style (even on Windows 7) doesn't look very similar.</p>
  
  <p>The ListView has its View set to a GridView with some GridViewColumns. The XAML for the ListView without any style applied is as such:</p>
  
  <pre><code>              &lt;ListView ItemsSource="{Binding Series.ServiceSeries.Weeks}"&gt;
                  &lt;ListView.View&gt; 
                      &lt;GridView&gt;
                          &lt;GridView.Columns&gt;
                              &lt;GridViewColumn Header="" DisplayMemberBinding="{Binding WeekNumber}" /&gt;
                              &lt;GridViewColumn Header="Start date" DisplayMemberBinding="{Binding Path=., Converter={StaticResource WeekConverter}, ConverterParameter=start}" /&gt;
                              &lt;GridViewColumn Header="Track" DisplayMemberBinding="{Binding Path=., Converter={StaticResource WeekConverter}, ConverterParameter=track}" /&gt;
                              &lt;GridViewColumn Header="Race length" DisplayMemberBinding="{Binding Path=., Converter={StaticResource WeekConverter}, ConverterParameter=length}" /&gt;
                          &lt;/GridView.Columns&gt;
                      &lt;/GridView&gt;
                  &lt;/ListView.View&gt;
              &lt;/ListView&gt;
  </code></pre>
  
  <p>It looks like this on Windows 7, as you can see the colors are slightly wrong:
  <a href="http://www.nickthissen.nl/Images/Persistent/tmp3DCB.png" rel="noreferrer">1 http://www.nickthissen.nl/Images/Persistent/tmp3DCB.png</a></p>
  
  <p>So I decided to apply a custom style to the ItemContainerStyle of the ListView. The Style is an almost exact copy of a style I'm using for a List<em>Box</em>, except replacing ListBoxItem by ListViewItem:</p>
  
  <pre><code>                    &lt;Style TargetType="{x:Type ListViewItem}" x:Key="ListViewItemStyle"&gt;
                      &lt;Setter Property="OverridesDefaultStyle" Value="True" /&gt;
                      &lt;Setter Property="SnapsToDevicePixels" Value="True" /&gt;
                      &lt;Setter Property="Template"&gt;
                          &lt;Setter.Value&gt;
                              &lt;ControlTemplate TargetType="{x:Type ListViewItem}"&gt;
  
                                  &lt;Border x:Name="Border" CornerRadius="3" BorderThickness="1" SnapsToDevicePixels="True"&gt;
                                      &lt;Border x:Name="InnerBorder" CornerRadius="2" BorderBrush="Transparent" Background="Transparent"
                              BorderThickness="1" Padding="3,1" SnapsToDevicePixels="True"&gt;
  
                                          &lt;ContentPresenter /&gt;
  
                                      &lt;/Border&gt;
                                  &lt;/Border&gt;
  
                                  &lt;ControlTemplate.Triggers&gt;
  
                                      &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                                          &lt;Setter TargetName="Border" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemHoverBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemHoverInnerBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="Background"
                                  Value="{StaticResource ListboxItemHoverBackground}" /&gt;
                                      &lt;/Trigger&gt;
                                      &lt;Trigger Property="IsSelected" Value="True"&gt;
                                          &lt;Setter TargetName="Border" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemSelectedBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemSelectedInnerBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="Background"
                                  Value="{StaticResource ListboxItemSelectedBackground}" /&gt;
                                      &lt;/Trigger&gt;
  
                                      &lt;MultiTrigger&gt;
                                          &lt;MultiTrigger.Conditions&gt;
                                              &lt;Condition Property="IsSelected" Value="true" /&gt;
                                              &lt;Condition Property="Selector.IsSelectionActive" Value="false" /&gt;
                                          &lt;/MultiTrigger.Conditions&gt;
                                          &lt;Setter TargetName="Border" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemInactiveBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="BorderBrush"
                                  Value="{StaticResource ListboxItemInactiveInnerBorder}" /&gt;
                                          &lt;Setter TargetName="InnerBorder" Property="Background"
                                  Value="{StaticResource ListboxItemInactiveBackground}" /&gt;
                                      &lt;/MultiTrigger&gt;
  
                                  &lt;/ControlTemplate.Triggers&gt;
                              &lt;/ControlTemplate&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                  &lt;/Style&gt;
  </code></pre>
  
  <p>After applying this style to the ItemContainerStyle property of the ListView, the ListView looks like this:
  <a href="http://www.nickthissen.nl/Images/Persistent/tmpCCB2.png" rel="noreferrer">2 http://www.nickthissen.nl/Images/Persistent/tmpCCB2.png</a></p>
  
  <p>As you can see, the colors are now much better, but it has completely lost its GridView display style, instead it's ignoring the columns completely and just inserting the ToString representation of the objects (which I did not override so it's returning the full type name).</p>
  
  <p>I don't understand why this happens and nothing I do gets rid of it, except removing the ItemContainerStyle. There must be something wrong with my style but I cannot find the problem...</p>
  
  <p>Can anyone see what I did wrong and how I can get my GridView style back? Thanks!</p>