Skip to main content

FormatCondition.Expression Property

Specifies the expression used to apply a conditional format. This is a dependency property.

Namespace: DevExpress.WinUI.Grid

Assembly: DevExpress.WinUI.Grid.v23.2.dll

NuGet Package: DevExpress.WinUI

Declaration

[DP(null, Handler = "RaiseChanged")]
public string Expression { get; set; }

Property Value

Type Description
String

A string value that specifies the expression used to apply a conditional format.

Remarks

The XAML snippet below illustrates how to change the font color to green for positive values in the Profit column.

<dxg:GridControl.FormatConditions>
    <dxg:FormatCondition FieldName="Profit" Expression="[Profit] &gt; 0" PredefinedFormatName="GreenText"/>
</dxg:GridControl.FormatConditions>

The code sample below illustrates how to define the same conditional format in code-behind.

var profitFormatCondition = new FormatCondition() {
    FieldName = "Profit",
    Expression = "[Profit] > 0",
    PredefinedFormatName = "GreenText"
};
gridControl.FormatConditions.Add(profitFormatCondition);

The image below shows the result.

DevExpress WinUI Grid - Format Conditions

Use the ValueRule property to specify a predefined rule for conditional formatting.

See Also