Skip to main content

PivotGridControl.FieldCellTemplate Property

Gets or sets a template used to display data cells. This is a dependency property.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v24.1.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public DataTemplate FieldCellTemplate { get; set; }

Property Value

Type Description
DataTemplate

A DataTemplate object used to display data cells.

Remarks

The FieldCellTemplate is applied to those cells, whose field’s PivotGridField.CellTemplate property is set to null. The PivotGridField.ActualCellTemplate property allows you to obtain which template is currently used for a particular field’s data cells.

You can implement custom logic to choose the required template using the PivotGridControl.FieldCellTemplateSelector property (or the PivotGridField.CellTemplateSelector property to do this for individual fields).

If a field displays KPI graphics, the PivotGridControl.FieldCellKpiTemplate and PivotGridControl.FieldCellKpiTemplateSelector properties are used for this field.

Example

The following example demonstrates how to use the PivotGridControl.FieldCellTemplate property to customize the appearance of data cells.

<Window x:Class="HowToCustomizeCellTemplate.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:HowToCustomizeCellTemplate"
        Title="Custom Cell Template" Height="450" Width="800"  Loaded="Window_Loaded">
    <Grid>
        <dxpg:PivotGridControl x:Name="pivotGridControl1">
            <dxpg:PivotGridControl.Fields>
                <dxpg:PivotGridField
                    x:Name="fieldSales"
                    Area="DataArea"
                    Caption="Product Sales"
                    FieldName="ExtendedPrice">
                </dxpg:PivotGridField>
                <dxpg:PivotGridField
                    x:Name="fieldYear"
                    AllowFilter="False"
                    Area="ColumnArea"
                    Caption="Year"
                    FieldName="OrderDate"
                    GroupInterval="DateYear" />
                <dxpg:PivotGridField
                    x:Name="fieldMonth"
                    AllowFilter="False"
                    Area="ColumnArea"
                    Caption="Month"
                    FieldName="OrderDate"
                    GroupInterval="DateMonth" />
                <dxpg:PivotGridField
                    x:Name="fieldCategoryName"
                    Area="RowArea"
                    AreaIndex="0"
                    Caption="Category"
                    FieldName="CategoryName" />
                <dxpg:PivotGridField
                    x:Name="fieldProductName"
                    Area="RowArea"
                    AreaIndex="1"
                    Caption="Product"
                    FieldName="ProductName" />
            </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>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FieldCellTemplate property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also