我认为我有以下XAML:
<tg:RadDataGrid ColumnDataOperationsMode="Flyout" x:Name="grid3" ItemsSource="{x:Bind ViewModel.MappingSource}" SelectedItem="{x:Bind ViewModel.CurrentMapping, Mode=TwoWay}" UserEditMode="{x:Bind ViewModel.CanEdit, Mode=TwoWay}" Grid.ColumnSpan="4" Grid.Row="1" AutoGenerateColumns="False" RowBackground="{x:Bind ViewModel.ValidateModBank}">
请查看它设置RowBackground
属性的行的末尾。此时,我的ValidateModBank
属性根据特定条件返回红色。
问题是RadDataGrid
中的所有行都变为红色,但我只想要更改特定的行 - 基于ValidateModBank
。
我怎样才能做到这一点?
RowBackground
属性用于设置定义每行填充的Brush,而不是特定行。
根据您的描述,您可能想要更改所选行的背景。
你可以使用它的Implicit Styling。
为它设置SelectionRegionBackground Control。
<telerikGrid:RadDataGrid.Resources>
<Style TargetType="gridPrimitives:SelectionRegionBackgroundControl">
<Setter Property="Background" Value="Red"/>
<Setter Property="BorderBrush" Value="Green"/>
<Setter Property="BorderThickness" Value="2"/>
</Style>
</telerikGrid:RadDataGrid.Resources>