FormatConditionBase.Expression Property

Gets or sets the expression used to apply a conditional format. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.Core.dll

Declaration

public string Expression { get; set; }
Public Property Expression As String

Property Value

Type Description
String

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

Remarks

Use the Expression property to specify a condition for expression based conditional formats (ExpressionConditionBase class descendants). Refer to the Formatting Values Using Custom Conditions topic to learn more.

The Expressions Overview topic contains a list of operators, functions and constants you can use in the expressions.

The code sample below illustrates how to define a conditional format with an expression in markup.

<dxg:TableView.FormatConditions>
   <dxg:FormatCondition Expression="Contains([Symbol], 'AT')" FieldName="Symbol" PredefinedFormatName="LightRedFillWithDarkRedText" />      
</dxg:TableView.FormatConditions>

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

var symbolFormatCondition = new FormatCondition() {
   Expression = "Contains([Symbol], 'AT')",
   FieldName = "Symbol",
   PredefinedFormatName = "LightRedFillWithDarkRedText"
};
view.FormatConditions.Add(symbolFormatCondition);

For indicator-type conditional formats (IndicatorFormatConditionBase class descendants) use the Expression property to specify a complex custom expression that returns a value based on several parameters (e.g., several columns in a row). See the following topics to learn more:

The following code sample illustrates how to define in markup a conditional format with an expression that returns a value based on NewPrice and OldPrice columns:

<dxg:TableView.FormatConditions>
   <dxg:IconSetFormatCondition Expression="Abs([NewPrice] - [OldPrice])" FieldName="Price" PredefinedFormatName="TrafficLights3UnrimmedIconSet"/>     
</dxg:TableView.FormatConditions>

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

var priceFormatCondition = new IconSetFormatCondition() {
   Expression = "Abs([NewPrice] - [OldPrice])",
   FieldName = "Price",
   PredefinedFormatName = "TrafficLights3UnrimmedIconSet"
};
view.FormatConditions.Add(priceFormatCondition);
See Also