Back to Devexpress

FormatConditionBase.Expression Property

wpf-devexpress-dot-xpf-dot-pivotgrid-dot-formatconditionbase-81fd6e23.md

latest3.2 KB
Original Source

FormatConditionBase.Expression Property

Gets or sets the expression used to apply the corresponding conditional formatting rule. This is a dependency property.

Namespace : DevExpress.Xpf.PivotGrid

Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

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

Property Value

TypeDescription
String

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

|

Remarks

Use the Expression property to specify a condition for expression based conditional formats (ExpressionConditionBase class descendants). Refer to the Conditional Formatting topic to learn more about conditions.

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.

xaml
<dxpg:PivotGridControl.FormatConditions>
    <dxpg:FormatCondition ColumnName="Category" MeasureName="Category" Expression="Contains([Category], 'ai')" PredefinedFormatName="LightRedFillWithDarkRedText"/>
</dxpg:PivotGridControl.FormatConditions>

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

csharp
var symbolFormatCondition = new FormatCondition() {
    Expression = "Contains([Category], 'ai')",
    RowName = "Category",
    MeasureName = "Category",
    PredefinedFormatName = "LightRedFillWithDarkRedText"
};
pivotGridControl1.FormatConditions.Add(symbolFormatCondition);
vb
Dim symbolFormatCondition = New FormatCondition() With {
    .Expression = "Contains([Category], 'ai')",
    .RowName = "Category",
    .MeasureName = "Category",
    .PredefinedFormatName = "LightRedFillWithDarkRedText"
};
pivotGridControl1.FormatConditions.Add(symbolFormatCondition)

For indicator-type conditional formats (IndicatorFormatConditionBase class descendants) you can 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 Also

FormatConditionBase Class

FormatConditionBase Members

DevExpress.Xpf.PivotGrid Namespace