Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

set Foreground color of Selected Row in DataGrid

$
0
0

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


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>