更改Telerik UWP RadDataGrid中特定行的颜色

问题描述 投票:1回答:1

我认为我有以下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

我怎样才能做到这一点?

c# xaml uwp telerik telerik-grid
1个回答
0
投票

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>
© www.soinside.com 2019 - 2024. All rights reserved.