DevExpress GridControl:将行的背景颜色绑定到模型的属性

问题描述

我正在测试 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}" />

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...