我认为以下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
。
我该如何实现?
答案 0 :(得分:0)
RowBackground
属性用于设置定义每行填充的“画笔”,而不是特定行的填充。
根据您的描述,您可能想要更改所选行的背景。
您可以使用其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>