views:

342

answers:

2

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

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

When this happends, the column's background in which the mouse is over should be yellow and all the color in the other columns should be, let's say, blue.

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

+1  A: 

In order to do this, I think you're going to have to replace the entire ListView style. Microsoft has an example.

You'll have to put a Border around the GridViewHeaderRowPresenter in the ScrollViewer style shown in there and add an IsMouseOver trigger to set the background of that Border to Blue.

Then, of course, you'll need an IsMouseOver trigger on the GridViewColumnHeader template to make the background yellow.

If you need any further explanation, please ask.

-- HTH, Dusty

dustyburwell
i guess the solution that i found is similar in idea to the one you mention, only that yours requires a styling the scrollviewer, and mine would be in the GridViewColumnHeader directly. Thanks anyways!
federubin
A: 

Finally i found a way to do this. Basically you set a trigger that will see if the parent GridViewHeaderRowPresenter is selected. All headers will return true to that property.

Then you check if the header has mouseover, and only the selected header will return true

Something like this:

<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>
federubin