I'm having a datagrid(WPF) with some items(ListViewCollection). I have one problem. I select one row, after that I sort by a column. The selected row changes it's background.
Below i have the datagrid code. And 2 screen pictures with before/after. You can see that the blue color turns in grey
<DataGrid Background="White" IsSynchronizedWithCurrentItem="{x:Null}" EnableRowVirtualization="False" AutoGenerateColumns="False" CanUserSortColumns="True" ItemsSource="{Binding ConsoleLines}"
GridLinesVisibility="None" IsReadOnly="True" RowHeaderWidth="0" Style="{StaticResource DataGridStyle}" Margin="5">
<DataGrid.Columns>
<DataGridTemplateColumn CanUserSort="True" Header="{Binding TimeHeader, Source={StaticResource ResLoc}}" SortMemberPath="Time" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Time}" TextWrapping="Wrap" Foreground="{StaticResource DarkBackgroundBrush}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserSort="True" Header="{Binding MessageHeader, Source={StaticResource ResLoc}}" SortMemberPath="Message" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Message}" TextWrapping="Wrap" Foreground="{StaticResource DarkBackgroundBrush}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserSort="True" Header="{Binding CategoryHeader, Source={StaticResource ResLoc}}" SortMemberPath="Category" Width="150">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Category}" TextWrapping="Wrap" Foreground="{StaticResource DarkBackgroundBrush}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>