You can bind the Background
in the RowStyle
for DataGrid
<DataGrid ...>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="{Binding MyBackground}"/>
</Style>
</DataGrid.RowStyle>
<!-- ... -->
</DataGrid>
This will work if MyBackground
is a Brush
. You mention in your question that you have a Color
, if this is the case you can use this instead
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{Binding MyColor}"/>
</Setter.Value>
</Setter>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…