Version

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.

Topic Purpose

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.

Control Configuration Summary

Control configuration overview

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.

Specifying custom templates for column and/or row header cells

In addition to data cells you can specify custom templates for header cells too.

Specifying Custom Templates for Data Cells

Overview

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

xamPivotGrid Customizing Cells with Templates Overview 1.png

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

xamPivotGrid Customizing Cells with Templates Overview 2.png

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

xamPivotGrid Customizing Cells with Templates Overview 3.png

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic is a step-by-step walkthrough on how to customize xamPivotGrid™ cells by applying custom DataTemplates for their content.

This is a list of the most notable properties related to the Cell customization feature of the xamPivotGrid.

Explanation on how to use the CellControlAttached event to apply custom styles to data cells based on the cell’s value.