Back to Devexpress

Format Class

wpf-devexpress-dot-xpf-dot-core-dot-conditionalformatting-c4eeb725.md

latest5.5 KB
Original Source

Format Class

Contains formatting settings for a value based conditional format.

Namespace : DevExpress.Xpf.Core.ConditionalFormatting

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public class Format :
    Freezable
vb
Public Class Format
    Inherits Freezable

The following members return Format objects:

Remarks

The Format class instances are used to set the GridControl’s ExpressionConditionBase.Format and PivotGridControl’s ExpressionConditionBase.Format properties.

The code sample below illustrates how to create the top-bottom conditional formatting rule with a custom format in markup for GridControl.

xaml
<dxg:TableView.FormatConditions> 
   <dxg:TopBottomRuleFormatCondition Rule="TopItems" Threshold="20" FieldName="Profit">
      <dx:Format Background="Purple"/> 
   </dxg:TopBottomRuleFormatCondition> 
</dxg:TableView.FormatConditions>

The code sample below illustrates how to define the same conditional formatting rule in code-behind for GridControl.

csharp
var profitFormatCondition = new TopBottomRuleFormatCondition() {
   Rule = TopBottomRule.TopItems,
   Threshold = 20,    
   FieldName = "Profit", 
   Format = new Format() {
      Background = Brushes.Purple
   }
};
view.FormatConditions.Add(profitFormatCondition);
vb
Dim profitFormatCondition = New TopBottomRuleFormatCondition() With {
   .Rule = TopBottomRule.TopItems,
   .Threshold = 20,
   .FieldName = "Profit",
   .Format = new Format() With {
      .Background = Brushes.Purple
   }
}
view.FormatConditions.Add(profitFormatCondition)

The following code snippets (auto-collected from DevExpress Examples) contain references to the Format class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-disable-rows-based-on-their-values/CS/WpfApplication/MainWindow.xaml#L47

xml
<dxg:FormatCondition.Format>
    <dx:Format Foreground="Gray" Background="LightGray"/>
</dxg:FormatCondition.Format>

wpf-grid-scrollbar-annotations/CS/WpfApplication25/MainWindow.xaml#L32

xml
<dxg:FormatCondition Expression="[Number] &gt; 2.0m and [Number] &lt; 4.0m" FieldName="Number" ApplyToRow="True">
    <dx:Format Background="Green"/>
</dxg:FormatCondition>

wpf-data-grid-apply-conditional-formatting/CS/ConditionalFormatting/MainWindow.xaml#L27

xml
<dxg:FormatCondition Expression="[Profit] &lt; 0.0" FieldName="Profit">
    <dx:Format Foreground="Red"/>
</dxg:FormatCondition>

wpf-pivot-grid-apply-format-conditions-to-data-cells/CS/WpfPivotGridConditionalFormatting/MainWindow.xaml#L34

xml
Rule="TopItems">
    <dx:Format Background="#FF90EE90" Foreground="#FF008000" />
</dxpg:TopBottomRuleFormatCondition>

Inheritance

Object DispatcherObject DependencyObject Freezable Format Format

See Also

Format Members

Conditional Formatting

Formatting Values Using Comparison Rules

Conditional Formatting

DevExpress.Xpf.Core.ConditionalFormatting Namespace