tags:

views:

3766

answers:

2

Anyone know how to style the header hover color of a WPF ListView?

Thanks!

+4  A: 

You have to create style for GridView.ColumnHeaderContainerStyle property. Add the hover effect by setting some trigger to the Style. sample XAML bellow

 <ListView VerticalAlignment="Bottom" Height="63" IsSynchronizedWithCurrentItem="True">
        <ListView.View>
         <GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle1}" >
          <GridViewColumn/>
         </GridView>
        </ListView.View>
    </ListView>

And the Style can be created as bellow, the bellow code will create Green color on hover over

  <Style x:Key="GridViewColumnHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>
Jobi Joy
Dude, thank you. Rock on!
xanadont
+1  A: 

This doesn't work for me on Vista. Default colors are applied.

Any workarounds?

I'm not sure, but try setting `OverridesDefaultStyle` to `True`. This should prevent Windows from applying any default styles to the control, if I remember correctly.
Deniz Dogan