WPF DataGrid MouseOver on DataGridRow
23,448
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?
Author by
esylvestre
Updated on July 09, 2022Comments
-
esylvestre almost 2 years
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...
-
esylvestre over 13 yearsDamn, on a simple DataGrid (from a new project), it works. I'm gonna post my complete DataGrid to show you.
-
esylvestre over 13 yearsGot my error. I was setting the RowBackground property on my Datagrid, which has priority on the RowStyle. My bad, thanks for the hint!