WPF的DataGrid鼠标悬停在DataGridRow [英] WPF DataGrid MouseOver on DataGridRow

查看:1992
本文介绍了WPF的DataGrid鼠标悬停在DataGridRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不通为什么code中的第一部分不工作,但第二个。

I can't figure out why the first part of code isn't working, but the second is.

第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

PART 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...

推荐答案

老兄,我复制粘贴你有什么它完美对我很好。我不知道你有什么问题。还有什么在你的XAML,可能是相关的?此外,您还可以尝试添加&LT; setter属性=背景值=透明/&GT; 您DataGridRow的风格,看看它是否修复它。

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?

这篇关于WPF的DataGrid鼠标悬停在DataGridRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆