Skip to main content
A newer version of this page is available. .

How to: Customize the Cell Template

  • 2 minutes to read

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

<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>