.net DataGridRow 上的 WPF DataGrid MouseOver
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3418904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF DataGrid MouseOver on DataGridRow
提问by esylvestre
I can't figure out why the first part of code isn't working, but the second is.
我不明白为什么代码的第一部分不起作用,但第二部分是。
PART 1
第1部分
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
PART 2
第2部分
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="Pink" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
Basically, all I want to do is set the MouseOver color on a row...
基本上,我想要做的就是在一行上设置鼠标悬停颜色......
采纳答案by ASanch
Dude, I copy-pasted what you have it works perfectly fine for me. I'm not sure what issue you're having. Is there anything else in your XAML that could be relevant? Also, can you try adding a <Setter Property="Background" Value="Transparent"/>to your DataGridRow's style and see if it fixes it?
伙计,我复制粘贴了你拥有的东西,它对我来说非常好。我不确定你遇到了什么问题。您的 XAML 中还有其他可能相关的内容吗?另外,您可以尝试<Setter Property="Background" Value="Transparent"/>在 DataGridRow 的样式中添加 a并查看它是否修复了吗?

