wpf-118929-controls-and-libraries-data-grid-conditional-formatting-conditional-formats-formatting-changing-values.md
The Data Update conditional format allows you to visualize changing values in real time:
Run Demo: Data Update Animation
Note
Set the TableView.AllowDataUpdateFormatConditionMenu (or TreeListView.AllowDataUpdateFormatConditionMenu) property to true to enable creating the data update conditional formats.
This topic consists of the following sections:
Create the DataUpdateFormatCondition class instance and specify the following settings to create the Data Update conditional format in code:
Specify the data update rule, that determines when data update formatting should be applied, using the DataUpdateFormatCondition.Rule property. To define a custom logic, set the DataUpdateFormatCondition.Rule property to DataUpdateRule.Custom and handle the TableView.CustomDataUpdateFormatCondition (or TreeListView.CustomDataUpdateFormatCondition) event.
Use the FormatConditionBase.FieldName property to specify the column’s field name to which to apply the conditional format.
Specify the target cells’ formatting:
Add the resulting DataUpdateFormatCondition instance to the TableView.FormatConditions (or TreeListView.FormatConditions) collection.
The following code sample illustrates how to define a conditional format in markup:
<dxg:TableView.FormatConditions>
<dxg:DataUpdateFormatCondition Rule="Increase" FieldName="Change" PredefinedFormatName="GreenFillWithDarkGreenText"/>
</dxg:TableView.FormatConditions>
The code sample below illustrates how to define the same conditional format in code-behind:
var changeFormatCondition = new DataUpdateFormatCondition() {
Rule = DataUpdateRule.Increase,
FieldName = "Change",
PredefinedFormatName = "GreenFillWithDarkGreenText"
};
view.FormatConditions.Add(changeFormatCondition);
Dim changeFormatCondition = New DataUpdateFormatCondition() With {
.Rule = DataUpdateRule.Increase,
.FieldName = "Change",
.PredefinedFormatName = "GreenFillWithDarkGreenText"
}
view.FormatConditions.Add(changeFormatCondition)
The Data Update conditional format works with animation effects. To change animation effects, create the DataUpdateAnimationSettings class instance with required settings, and assign the resulting object to the DataUpdateFormatCondition.AnimationSettings property.
View Example: Use Format Conditions to Animate Data Changes
The following code sample illustrates how to change animation effects in markup:
<dxg:TableView.FormatConditions>
<dxg:DataUpdateFormatCondition FieldName="DeltaPrice" Rule="Always" PredefinedFormatName="LightRedFillWithDarkRedText">
<dxg:DataUpdateFormatCondition.AnimationSettings>
<dx:DataUpdateAnimationSettings EasingMode="Linear" HideDuration="0:0:2" HoldDuration="0:0:6" ShowDuration="0:0:2" />
</dxg:DataUpdateFormatCondition.AnimationSettings>
</dxg:DataUpdateFormatCondition>
</dxg:TableView.FormatConditions>
The code sample below illustrates how to change animation effects in code-behind:
var deltaPriceFormatCondition = new DataUpdateFormatCondition() {
FieldName = "DeltaPrice",
Rule = DataUpdateRule.Always,
PredefinedFormatName = "LightRedFillWithDarkRedText",
AnimationSettings = new DataUpdateAnimationSettings() {
EasingMode = AnimationEasingMode.Linear,
HideDuration = new Duration(new TimeSpan(0, 0, 2)),
HoldDuration = new Duration(new TimeSpan(0, 0, 6)),
ShowDuration = new Duration(new TimeSpan(0, 0, 2))
}
};
view.FormatConditions.Add(deltaPriceFormatCondition);
Dim deltaPriceFormatCondition = New DataUpdateFormatCondition() With {
.FieldName = "DeltaPrice",
.Rule = DataUpdateRule.Always,
.PredefinedFormatName = "LightRedFillWithDarkRedText",
.AnimationSettings = New DataUpdateAnimationSettings() With {
.EasingMode = AnimationEasingMode.Linear,
.HideDuration = New Duration(New TimeSpan(0, 0, 2)),
.HoldDuration = New Duration(New TimeSpan(0, 0, 6)),
.ShowDuration = New Duration(New TimeSpan(0, 0, 2))
}
}
view.FormatConditions.Add(deltaPriceFormatCondition)
Use the following grid view properties to define animation duration for all data update conditional formats within the current grid’s view:
|
TableView.DataUpdateAnimationShowDuration (TreeListView.DataUpdateAnimationShowDuration)
|
Gets or sets the data update formatting show duration.
| |
TableView.DataUpdateAnimationHoldDuration (TreeListView.DataUpdateAnimationHoldDuration)
|
Specifies the data update formatting hold duration.
| |
TableView.DataUpdateAnimationHideDuration (TreeListView.DataUpdateAnimationHideDuration)
|
Gets or sets the data update formatting hide duration.
|
The Data Update conditional format is not supported in the multiple selection mode.
See Also