Thank you for your feedback! You have rated this topic in the last 30 days.
Customizing Cells with Templates Overview (xamPivotGrid)
Topic Overview
Purpose
The xamPivotGrid™ control enables you to specify custom data templates for data cells and for header column and row cells. This topic is an overview of this feature.
Required background
The following table lists the topics required as a prerequisite to understanding this topic.
This section serves as an introduction to the xamPivotGrid control’s key features and functionalities. The topics listed here will give you a better idea of why you would want to use xamPivotGrid in your applications.
This topic demonstrates how to get started with the xamPivotGrid control by providing step-by-step procedure for adding this control to a WPF application.
The following table lists the configurable aspects of applying custom templates to xamPivotGrid cells.
Configurable aspects
Details
Properties
Specifying custom templates for data cells
The xamPivotGrid control provides the option to specify custom DataTemplate for a cell, or a group of cells. For example, all cells in a column, all cells in a row, all cells at some level etc.
The xamPivotGrid exposes the DataCellTemplates property. The type of this property is a collection of DataCellTemplate objects. The DataCellTemplate class serves as a container for a DataTemplate applied to the content of data cells of the xamPivotGrid. Additionally it has some properties used to determine which data cells the DataTemplate will be applied to.
Property settings
The following table maps the desired configuration to property settings.
In order to:
Use this property:
And set it to:
Apply custom data templates to data cells of the xamPivotGrid
DataCellTemplates
A collection of DataCellTemplate objects
Example
The screenshot below demonstrates how the xamPivotGrid looks when a DataCellTemplate with the following properties is added to its DataCellTemplates collection. The data source used is the SalesDataSample resource.
Property
Value
Template
A DataTemplate containing a Textblock with red foreground.
ColumnHierarchy
Product
ColumnLabel
Components
Specifying Custom Templates for Column and/or Row Header Cells
Overview
The xamPivotGrid exposes the RowHeaderTemplates and ColumnHeaderTemplates properties. The type of these properties is a collection of HeaderTemplate objects. The HeaderTemplate class is similar to the DataCellTemplate, but the properties that determine where the DataTemplate is applied, are applicable to header cells rather than data cells.
Property settings
The following table maps the desired configuration to property settings.
In order to:
Use this property:
And set it to:
Apply custom data templates to column header cells of the xamPivotGrid
ColumnHeaderTemplates
A collection of HeaderTemplate objects
Apply custom data templates to row header cells of the xamPivotGrid
RowHeaderTemplates
A collection of HeaderTemplate objects
RowHeader Template Example
The screenshot below demonstrates how the xamPivotGrid looks when a HeaderTemplate with the following properties is added to its RowHeaderTemplates collection.
Property
Value
Template
A DataTemplate containing a grid with light green background and a text block in it.
Hierarchy
Seller
Level
1
ColumnHeader Template Example
The screenshot below demonstrates how the xamPivotGrid looks when a HeaderTemplate with the following properties is added to its ColumnHeaderTemplates collection.
Property
Value
Template
A DataTemplate containing a grid with light green background and a text block in it.
Label
Bikes
Related Topics
The following topics provide additional information related to this topic.