views:

630

answers:

6

Hi

I'm trying to style the header of a listview depending on hover/pressed/etc. events.

So far I tried a few things such as a trigger like the following but this does not work on my machine (a Vista Ultimate x64)

<Style x:Key="GridViewColumnHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="true">
            <Setter Property="Background" Value="Green"/>
        </Trigger>
    </Style.Triggers>
</Style>

And the listview code:

     <ListView VerticalAlignment="Bottom" IsSynchronizedWithCurrentItem="True">
        <ListView.View>
            <GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle1}" >
                <GridViewColumn Header="abc"/>
                <GridViewColumn Header="cde"/>
            </GridView>
        </ListView.View>
        <ListView.DataContext>
            <DataTemplate>
                <ListViewItem Content="zxc"/>
            </DataTemplate>
        </ListView.DataContext>
    </ListView>

The behaviour I expect is for the background of the header that I hover to become green.

Any ideas?

NT

A: 

I knew this would be a tough one to crack...

A: 

Hi Jeremy,

The process you described does not work on mine, I still get the default blue color when I hover over the two column headers. Is is because you're not using Vista Ultimate x64? Is your OS perhaps XP?

Could someone with Vista get it to work (i.e. present a green color on hovering the 'abc' column)?

Regards,

_NT

Could be, I am on XP.
Jeremy Wilde
+1  A: 

I have reported this as a bug on Connect:

https://connect.microsoft.com/WPF/feedback/ViewFeedback.aspx?FeedbackID=475669

+1  A: 

This is confirmed as a bug, and will not be fixed in time for .NET framework 4.0 as per the MS drone's response in Microsoft Connect.

Hooray for closed source software yet again...

I'm hearing you ...
Run CMD
A: 

It has nothing to do with closed or open source - all projects have to prioritze bugs and issues and set a release. This one just did not make the cut off.

A: 

Yes it does.

If it were open-source, then I would've drilled down, fixed it and provided a patch myself. Then me and others who would use the "development" version would benefit in the mean time. Now we don't even know when it's getting fixed, if ever. There are so many bugs that have not been fixed for years in .NET and other closed source projects.

Closed source does not allow you to do this. And this is another reason why I will strive to use open source.

Regards NT