Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style a WPF's ListView Header's hover color

Tags:

wpf

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

Thanks!

like image 821
xanadont Avatar asked Dec 18 '22 09:12

xanadont


1 Answers

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

For example:

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


and the Style can be created like so:

  <Style x:Key="GridViewColumnHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>
like image 114
Jobi Joy Avatar answered Dec 30 '22 14:12

Jobi Joy