FormatCondition Class
Represents a format condition based on a specified rule(s) or expression.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
Declaration
Remarks
Use the FormatCondition condition to compare a data cell value with a specific constant(s) or expression.
The FormatCondition class is inherited from the FormatConditionBase base class and represents a format condition based on a specified rule(s) or expression. To apply the condition, create a new FormatCondition instance, specify its parameters and add it to the PivotGridControl.FormatConditions collection.
Specify the value rule using the FormatCondition.ValueRule property. To specify a constant(s), with which a value is compared, use the FormatCondition.Value1 and FormatCondition.Value2 properties.
For each condition, you can select one of the predefined formats using the FormatConditionBase.PredefinedFormatName property or apply a custom format by creating new Format collection and specifying its parameters.
For each condition, you can select one of the predefined formats or apply a custom format.
- Use the FormatConditionBase.PredefinedFormatName property to select one of the predefined formats.
- To apply a custom format, create a new Format instance, specify its parameters and assign this instance to the ExpressionConditionBase.Format property.
The following code sample shows how to apply FormatCondition with the predefined format and specified value rule.
using DevExpress.Xpf.PivotGrid;
using DevExpress.Xpf.Core.ConditionalFormatting;
public MainWindow()
{
// ...
// Creates a new FormatCondition instance.
FormatCondition formatRule = new FormatCondition();
// Configures the format condition.
formatRule.ApplyToSpecificLevel = true;
formatRule.ColumnName = "fieldQuarter";
formatRule.RowName = "fieldSalesPerson";
formatRule.MeasureName = "fieldExtendedPrice";
formatRule.ValueRule = ConditionRule.GreaterOrEqual;
formatRule.Value1 = 500;
formatRule.PredefinedFormatName = "GreenFillWithDarkGreenText";
// Adds this instance to the FormatConditionCollection.
pivotGridControl1.AddFormatCondition(formatRule);
}