Example E2191
Visible to All Users

Pivot Grid for WPF - How to Create a Field Value Template

This example shows how to define a custom template used to display field values. The template in this example displays field values with images, as shown in the picture below.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

HowToCreateFieldValueTemplate/MainWindow.xaml.cs
C#
using System.Data; using System.Windows; namespace HowToCreateFieldValueTemplate { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { DataTable salesPersonDataTable = new DataTable(); public MainWindow() { InitializeComponent(); pivotGridControl1.DataSource = salesPersonDataTable; } private void Window_Loaded(object sender, RoutedEventArgs e) { using (DataSourceHelper dataSourceHelper = new DataSourceHelper()) { dataSourceHelper.FillSalesPerson(salesPersonDataTable); } } } }
HowToCreateFieldValueTemplate/MainWindow.xaml
XAML
<Window x:Class="HowToCreateFieldValueTemplate.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid" xmlns:example="clr-namespace:HowToCreateFieldValueTemplate" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded" > <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="CategoriesControl.xaml" /> </ResourceDictionary.MergedDictionaries> <DataTemplate x:Key="ProductsTemplate" > <example:CategoriesControl /> </DataTemplate> </ResourceDictionary> </Window.Resources> <Grid> <dxpg:PivotGridControl Name="pivotGridControl1" DataProcessingEngine="Optimized"> <dxpg:PivotGridControl.Fields> <dxpg:PivotGridField Name="fieldCountry" Area="ColumnArea" > <dxpg:PivotGridField.DataBinding> <dxpg:DataSourceColumnBinding ColumnName="Country"/> </dxpg:PivotGridField.DataBinding> </dxpg:PivotGridField> <dxpg:PivotGridField Name="fieldCustomer" Area="ColumnArea" Caption="Customer" > <dxpg:PivotGridField.DataBinding> <dxpg:DataSourceColumnBinding ColumnName="Sales Person"/> </dxpg:PivotGridField.DataBinding> </dxpg:PivotGridField> <dxpg:PivotGridField Name="fieldYear" Area="RowArea" Caption="Year"> <dxpg:PivotGridField.DataBinding> <dxpg:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateYear"/> </dxpg:PivotGridField.DataBinding> </dxpg:PivotGridField> <dxpg:PivotGridField Name="fieldCategoryName" Area="RowArea" Caption="Product Category" ValueTemplate="{StaticResource ResourceKey=ProductsTemplate}"> <dxpg:PivotGridField.DataBinding> <dxpg:DataSourceColumnBinding ColumnName="CategoryName"/> </dxpg:PivotGridField.DataBinding> </dxpg:PivotGridField> <dxpg:PivotGridField Name="fieldExtendedPrice" Area="DataArea" CellFormat="c0" > <dxpg:PivotGridField.DataBinding> <dxpg:DataSourceColumnBinding ColumnName="ExtendedPrice"/> </dxpg:PivotGridField.DataBinding> </dxpg:PivotGridField> </dxpg:PivotGridControl.Fields> </dxpg:PivotGridControl> </Grid> </Window>

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.