Pivot Grid Elements That Support Templates
- 3 minutes to read
The following table lists all template properties introduced by the Pivot Grid:
Visual Element | Property | Description | Data Context (Binding Source) |
---|---|---|---|
Customization Form | Specifies the template that defines the presentation of the Customization Form. | ||
Data Cell | PivotGridControl.FieldCellTemplate PivotGridControl.FieldCellTemplateSelector PivotGridControl.FieldCellKpiTemplate | Specifies the template that defines the presentation of data cells. | DevExpress.Xpf.PivotGrid.Internal.CellsAreaItem |
Drag Indicator | Specifies the template that defines the presentation of the drag indicator. | null (Nothing in Visual Basic) | |
Field Header | PivotGridControl.FieldHeaderTemplate | Specifies the template that defines the presentation of field headers. | |
Field Header (in a Customization Form, list arrangement) | PivotGridControl.FieldHeaderListTemplate PivotGridControl.FieldHeaderListTemplateSelector | Specifies the template that defines the presentation of field headers in the Customization Form when they are arranged in a list. | |
Field Header (in a Customization Form, tree arrangement) | PivotGridControl.FieldHeaderTreeViewTemplate PivotGridControl.FieldHeaderTreeViewTemplateSelector | Specifies the template that defines the presentation of field headers in the Customization Form when they are arranged in a tree. | |
Field Value | PivotGridControl.FieldValueTemplate | Specifies the template that defines the presentation of field values. | DevExpress.Xpf.PivotGrid.Internal.FieldValueItem |
Focused Cell’s Border | Specifies the template that defines the presentation of the focused cell’s border. | null (Nothing in Visual Basic) | |
Resizing Indicator | Specifies the template that defines the presentation of the resizing indicator. | null (Nothing in Visual Basic) |
Example
The following example demonstrates how to use the PivotGridControl‘s PivotGridControl.FieldCellTemplate property to customize the appearance of data cells.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-the-cell-template-e2138.
<Window x:Class="HowToBindToMDB.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
xmlns:local="clr-namespace:HowToBindToMDB"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<dxpg:PivotGridControl HorizontalAlignment="Left" Name="pivotGridControl1"
VerticalAlignment="Top">
<dxpg:PivotGridControl.Fields>
<dxpg:PivotGridField Name="fieldCountry" FieldName="Country" Area="RowArea" />
<dxpg:PivotGridField Name="fieldSalesPerson" FieldName="Sales Person" Area="RowArea" />
<dxpg:PivotGridField Name="fieldYear" FieldName="OrderDate" Area="ColumnArea"
Caption="Year" GroupInterval="DateYear" />
<dxpg:PivotGridField Name="fieldExtendedPrice" FieldName="Extended Price" Area="DataArea"
CellFormat="c0" />
</dxpg:PivotGridControl.Fields>
<dxpg:PivotGridControl.FieldCellTemplate>
<DataTemplate>
<ProgressBar Name="cellShare" Minimum="0" Margin="3"
Maximum="{Binding Path=RowTotalValue, Mode=OneWay, Converter={local:RoundConverter}}"
Value="{Binding Path=Value, Mode=OneWay, Converter={local:RoundConverter}}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</DataTemplate>
</dxpg:PivotGridControl.FieldCellTemplate>
</dxpg:PivotGridControl>
</Grid>
</Window>