There is one DataGrid consisting of columns of type DataGridTemplateColumn.
An example of one of the columns:
<DataGridTemplateColumn Header="№" Width="20*"> <DataGridTemplateColumn.CellTemplate > <DataTemplate> <TextBlock Text="{Binding Path=Document.Number}" Foreground="{Binding Color}"></TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> Apparently from the code, in it binding on color is registered. Color changes in the code. You need to somehow change the color of the text when selecting the line. Tried to use triggers, unfortunately, did not work.
<DataGrid.CellStyle> <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <Trigger Property="IsSelected" Value="true"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </DataGrid.CellStyle> <DataGrid.RowStyle> <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <Trigger Property="IsSelected" Value="true"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </DataGrid.RowStyle>