Style Aggregate Results Displayed in the GroupHeaderRow
Environment
Product | RadGridView for WPF |
Description
How to change the style of the aggregates based on the results.
Solution
The approach would differ depending on the value of the ColumnAggregatesAlignment property of the RadGridView. If its value is NoAlignment (which is the default), the aggregate results are shown in GridViewAggregateResultCell elements. If its value is NextToGroupKey or BelowToGroupKey, the results are displayed in GridViewGroupHeaderCell elements. This article will show how you can conditionally style both elements.
Example 1 demonstrates a sample model and viewmodel that will be used for demonstration purposes.
Example 1: The model and viewmodel
Styling the GridViewAggregateResultCell elements
This approach is valid when the ColumnAggregatesAlignment of the RadGridView is NoAlignment. Example 2 shows how to create a style targeting GridViewAggregateResultCell and change its Background depending on its DataContext.
Example 2: Conditionally styling GridViewAggregateResultCell
Example 3: AggregateResultsListItemCountToBackgroundConverter implementation
Figure 1: Result from Example 2 in the Fluent theme
Styling the GridViewGroupHeaderCell elements
This approach is valid when the ColumnAggregatesAlignment of the RadGridView is NextToGroupKey or BelowToGroupKey. Example 4 shows how to create a style targeting GridViewGroupHeaderCell and change its Background depending on its DataContext.