esylvestre
esylvestre

Reputation: 1860

WPF DataGrid MouseOver on DataGridRow

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

PART 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

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

Upvotes: 21

Views: 27410

Answers (1)

ASanch
ASanch

Reputation: 10373

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?

Upvotes: 20

Related Questions