WPF ListView: Header Style

I want to have a ListView with columns and a specific style:

The background for ALL column headers should be transparent, except when the mouse ended in one of them.

When this happens, the background of the column in which the mouse is located should be yellow, and all the color in the other columns should be, say, blue.

I tried playing with the GridViewColumnHeader template, but this seems to only change the active background of the column. Any help?

+3
source share
2 answers

, : , , GridViewHeaderRowPresenter. true .

, , true.

:

<ControlTemplate.Triggers>
  <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                   AncestorType={x:Type GridViewHeaderRowPresenter}},
                                 Path=IsMouseOver}"
               Value="True">
    <Setter TargetName="HeaderBack" Property="Background"
            Value="{StaticResource HeaderActiveColumnBackground}"/>
    <Setter TargetName="PART_HeaderGripper" Property="Background"
            Value="{StaticResource VerticalLineColor}"/>
  </DataTrigger>
  <Trigger Property="IsMouseOver" Value="True">
    <Setter TargetName="HeaderBack" Property="Background"
            Value="{StaticResource HeaderSelectedColumnBackground}"/>
  </Trigger>
  <Trigger Property="HasContent" Value="false">
    <Setter TargetName="HeaderBack" Property="Background"
            Value="{StaticResource HeaderDefaultColumnNoContentBackground}"/>
    <Setter TargetName="PART_HeaderGripper" Property="Background"
            Value="{StaticResource HeaderDefaultColumnNoContentBackground}"/>
  </Trigger>
</ControlTemplate.Triggers>
+1

, , ListView. Microsoft .

Border GridViewHeaderRowPresenter ScrollViewer, , IsMouseOver, Border .

, , IsMouseOver GridViewColumnHeader, .

- , , .

- HTH, Dusty

+2

Source: https://habr.com/ru/post/1722184/


All Articles