WPF 列表视图标题悬停/按下颜色
我正在尝试根据悬停/按下/等来设置列表视图标题的样式。 事件。
到目前为止,我尝试了一些东西,例如像下面这样的触发器,但这在我的机器(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>
并且列表视图代码:
<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>
我期望的行为是我悬停的标题背景变成绿色。
有任何想法吗?
新台币
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我已将此报告为 Connect 上的错误:
https://connect。 microsoft.com/WPF/feedback/ViewFeedback.aspx?FeedbackID=475669
I have reported this as a bug on Connect:
https://connect.microsoft.com/WPF/feedback/ViewFeedback.aspx?FeedbackID=475669
这已被确认为一个错误,根据 Microsoft Connect 中 MS 无人机的响应,.NET Framework 4.0 不会及时修复。
再次为闭源软件万岁......
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...
是的,它确实。
如果它是开源的,那么我会深入研究、修复它并自己提供补丁。
那么我和其他使用“开发”版本的人将同时受益。
现在我们甚至不知道它什么时候能修复(如果有的话)。 .NET 和其他闭源项目中有很多错误多年来都没有得到修复。
闭源不允许你这样做。 这也是我会努力使用开源的另一个原因。
问候
新台币
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
只需采用 Microsoft 提供的控制模板并按照您认为合适的方式进行调整即可。 这就是我们删除 Microsoft 为每个控件添加的所有额外突出显示的方法。
您可以在此链接中找到模板:
http://msdn.microsoft.com/en-我们/库/aa970773(v=VS.100).aspx
Just take the provided Control Template Microsoft provides and adjust it how you see fit. That's how we remove all the additional highlighting Microsoft adds per control.
You can find the templates at this link:
http://msdn.microsoft.com/en-us/library/aa970773(v=VS.100).aspx