重置datagrid的非活动选择背景颜色

Qas*_*ash 3 wpf xaml datagrid

有没有办法DataGrid在焦点丢失时保留行的原始背景颜色?

我知道InactiveSelectionHighlightBrushKey可以设置一个特定的颜色,但可以说以前的背景颜色可能是红色或绿色,我想InactiveSelectionHighlightBrushKey 成为该行的原始颜色是什么?

添加:

我在viewmodel中有IsZero属性,它是true/false,以及下面的XAML:

          <DataGrid.RowStyle>
                <Style TargetType="{x:Type DataGridRow}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsZero}" Value="True">
                            <Setter Property="Background" Value="Green" />
                        </DataTrigger>
Run Code Online (Sandbox Code Playgroud)

其他行具有其他绑定以设置不同的颜色,但选择它并取消选择它会产生蓝色和灰色.我可以设置颜色,但不确定将其设置为"当前背景颜色"的优雅方式.

Ram*_*min 5

如果我理解正确,您可以使用此页面中的答案:DataGrid在非活动状态下选择的行颜色设置InactiveSelectionHighlightBrushKeyTransparent.