views:

67

answers:

1

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

+1  A: 

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?

karmicpuppet
Damn, on a simple DataGrid (from a new project), it works.I'm gonna post my complete DataGrid to show you.
esylvestre
Got my error. I was setting the RowBackground property on my Datagrid, which has priority on the RowStyle.My bad, thanks for the hint!
esylvestre