DevExpress GridControl: bind background color of the rows to a Model's property

709 Views Asked by At

I'm testing DevX GridControl (version 20.1). I need to bind the background colour of each row to a field in my model. I'v tried various ways, but all end with changing the background of all the rows of the grid using the background associated with the selected row. With an old version, i was able to manage that with:

<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>

I also tried conditional formatting, but I cannot figure out how to bind the background to my model.

1

There are 1 best solutions below

0
Luigi Boschetti On

Problem solved!

Just replace the Setter line with this one:

<Setter Property="Background" Value="{Binding Row.ColoreSfondo}" />