Reset inactive selection background color of datagrid

datagrid, wpf, xaml

Solution

If I understood correctly, you can use the answer in this page: DataGrid's selected row color when inactive to set the `InactiveSelectionHighlightBrushKey` to be `Transparent`.

Problem

Is there a way to retain the original background color of a row in `DataGrid` when the focus is lost? I know the `InactiveSelectionHighlightBrushKey` can set a specific color, but lets say the previous background color could be red or green, I want `InactiveSelectionHighlightBrushKey` to be whatever the the original color of the row was? Added: I have IsZero property in viewmodel which is true/false, and the below XAML: ``` <DataGrid.RowStyle> <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <DataTrigger Binding="{Binding IsZero}" Value="True"> <Setter Property="Background" Value="Green" /> </DataTrigger> ``` Other rows have other binding to set a different color, but selecting it and deselecting it gives blue and grey colors. I could set the colors, but not sure of an elegant way to set it to whatever the "current background color is."

Original source