问题描述
我正在测试 DevX GridControl(20.1 版)。我需要将每一行的背景颜色绑定到模型中的一个字段。 我尝试了各种方法,但都以使用与所选行关联的背景更改网格所有行的背景而告终。 使用旧版本,我可以通过以下方式进行管理:
<dxg:TableView AllowResizing="True" AutoWidth="True" ShowTotalSummary="True" >
<dxg:TableView.RowStyle>
<Style TargetType="{x:Type dxg:GridRowContent}">
<Setter Property="Background" Value="{Binding DataContext.DataModel.ColoreSfondo,ElementName=CDList}" />
</Style>
</dxg:TableView.RowStyle>
</dxg:TableView>
我也尝试过条件格式,但我不知道如何将背景绑定到我的模型。
解决方法
问题解决了!
只需用这个替换 Setter 行:
<Setter Property="Background" Value="{Binding Row.ColoreSfondo}" />