WPF的DataGrid鼠标悬停在DataGridRow鼠标、WPF、DataGrid、DataGridRow

2023-09-04 02:46:26 作者:屁股扭一扭国王就是我

我想不通为什么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?