I have a datagrid "Funds" bind to a listcollectionview.
I want to highlight specific rows in datagrid based on few rules. The fundGroupsList is the list of group names. The rule1 is to find the misalignment within members of a group.
One of the ways to do that is to create a boolean property (ex. IsRule1Failed ) in Entries and save the fail result foreach row .
Then, in XAML use DataTriggers to change the background color.
<DataGrid.Resources>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="BurlyWood" />
</Trigger>
<DataTrigger Binding="{Binding DataContext.IsRule1Failed}" Value="True">
<Setter Property="Background" Value="Red"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
You can also simply change the CSS Class of the row. GridView.SelectedRowStyle.CssClass = "selectedrow";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.