I wanted to set Background and Foreground of data grid rows based on triggers.
but for Selected DataGridRow it was not working. now after This link I am able to set background color. but Foreground color is still not working.
Solutions I tried:
1. set HighlightTextBrushKey to x:Null or Transparent in data grid resources.
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Transparent"/>
2. Change color of HighlightTextBrushKey on Selected event of DataGridRow. this works only when this event and not every-time when foreground color's trigger is fired.
void Row_Selected(object sender, RoutedEventArgs e) { var row = sender as DataGridRow; if (row != null) { DataGrid.Resources[SystemColors.HighlightTextBrushKey] = row.Foreground; } }
but still not getting expected results for foreground color. does HighlightTextBrushKey overrides foreground color? please help me out
Dheeraj