Hi everyone,
I'm having a bit of trouble with styling the rows in my WPF DataGrid. I want to apply a different background color to rows based on a property in my data item. I've tried using a DataTrigger within a Style on the DataGridRow, but it doesn't seem to be working as expected.
Here's a snippet of my XAML:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="Active">
<Setter Property="Background" Value="LightGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="Inactive">
<Setter Property="Background" Value="LightCoral" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
The Status property is a string. The DataGrid is bound to an ObservableCollection of objects that have a Status property.
Am I missing something obvious? Any help would be greatly appreciated!