I use a Datagrid. In that I put a List of Area like that:
ObservableCollection<Area> areas = new ObservableCollection<Area>();
...
datagrid.ItemsSource = areas;
Now I want to set the style of the rows according to a property of an Area.
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<!-- Compiler can't find UseForGroups -->
<Trigger Property="Area.UseForGroups" Value="True">
<Setter Property="Background" Value="LightCoral"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
How can I reference to Area.UseForGroups?
EDIT
I tried the following with DataTriggers but nothing happens
<DataGrid ...>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" >
<Style.Triggers>
<DataTrigger Binding="{Binding UseForGroups}" Value="True">
<Setter Property="Background" Value="LightCoral"/>
<Setter Property="Foreground" Value="Black"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
Here’s an example of using a DataTrigger
Note that you shouldn’t specify ‘Area.UseForGroups’ just ‘UseForGroups’ since the DataContext for an individual row is an Area.