# Devexpress Wpf Pivot Grid

> Build WPF applications with the DevExpress Pivot Grid (PivotGridControl) — a control for multi-dimensional data analysis displaying data in a cross-tabular pivot table. Use when adding PivotGridControl to a WPF project, binding to DataSet/DataTable, Entity Framework, OLAP cubes, server-mode sources, or in-memory data; creating PivotGridField objects and positioning them in Row/Column/Data/Filter…

- **Type:** Skill
- **Install:** `agentstack add skill-devexpress-agent-skills-devexpress-wpf-pivot-grid`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [DevExpress](https://agentstack.voostack.com/s/devexpress)
- **Installs:** 0
- **Category:** [Data & Analytics](https://agentstack.voostack.com/c/data-and-analytics)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [DevExpress](https://github.com/DevExpress)
- **Source:** https://github.com/DevExpress/agent-skills/tree/main/plugins/dx-wpf/skills/devexpress-wpf-pivot-grid
- **Website:** https://www.devexpress.com

## Install

```sh
agentstack add skill-devexpress-agent-skills-devexpress-wpf-pivot-grid
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# DevExpress WPF Pivot Grid (PivotGridControl)

The DevExpress WPF Pivot Grid (`DevExpress.Xpf.PivotGrid.PivotGridControl`) creates pivot tables for multi-dimensional data analysis. Large data sets are summarized in a cross-tabular layout that end users can sort, group, filter, drill down into, and visualize with charts or KPIs. Fields are positioned in four header areas — **Row**, **Column**, **Data**, **Filter** — and users can drag them between areas at runtime to reshape the report. Unlike `GridControl` (which uses `ItemsSource`), the Pivot Grid binds via the `DataSource` property and creates `PivotGridField` objects bound to columns of that source.

> **PivotGrid vs. GridControl**: `GridControl` is for tabular records — each row is one record. `PivotGridControl` is for **aggregated** data — each cell is a calculation (sum, count, average) at the intersection of row and column field values. If you need to show a list of orders, use `GridControl`. If you need to see "total sales per Country × Year", use `PivotGridControl`.

## When to Use This Skill

Use this skill when you need to:

- Build a cross-tab report from a `DataTable`, list, or query result
- Bind to a Microsoft Analysis Services OLAP cube
- Bind to a server-mode source (very large data, server-side aggregation)
- Bind to in-memory data (`List`) with the Optimized processing engine
- Bind asynchronously (background-thread data fetch and aggregation)
- Create fields in the Row, Column, Data, or Filter area programmatically
- Apply grouping intervals (`DateYear`, `DateMonth`, `Alphabetical`, custom numeric ranges)
- Customize aggregation functions (Sum, Count, Average, Min, Max, Custom)
- Add KPI displays for executive dashboards
- Apply conditional formatting (Excel-style cell formatting)
- Integrate with `ChartControl` for visual drill-down
- Print, preview, or export to PDF / XLSX / HTML / CSV / RTF / MHT / TXT
- Save and restore pivot layout across sessions
- Migrate from Microsoft `PivotTable` or third-party pivot controls

## Prerequisites & Installation

### NuGet Packages

| Package | Purpose |
|---------|---------|
| `DevExpress.Wpf.PivotGrid` | Main package — `PivotGridControl`, `PivotGridField`, all bindings |
| `DevExpress.Wpf.Printing` | Required for Print Preview and export |
| `DevExpress.Wpf.Charts` | Optional, for Chart integration |

All DevExpress packages in a project must share the same version.

### .NET (6/7/8+)

```bash
dotnet add package DevExpress.Wpf.PivotGrid
```

Add `net8.0-windows` and `true` to `.csproj`. Pivot Grid is Windows-only.

### .NET Framework (4.6.2+)

See [references/getting-started-dotnet-fw.md](references/getting-started-dotnet-fw.md).

**Important**: All DevExpress packages in a project must share the same version. A valid DevExpress license is required.

## Before You Start — Ask the Developer

Before generating code, ask these questions to avoid rework:

### General Questions
1. **Target framework**: .NET 8+, .NET 6/7, or .NET Framework 4.x?
2. **New or existing project**: Creating a new WPF app, or adding `PivotGridControl` to an existing one?
3. **DevExpress version**: Which version (e.g., 24.2, 25.1, 26.1)? All DX packages must use the same version.

### WPF and Setup
4. **Designer or code**: Visual Studio designer + toolbox, or code-only / MVVM?

### Pivot Grid–Specific
5. **Data binding mode**: Which best describes the data?
   - **In-Memory / Optimized** — collection of POCOs or `DataTable`, aggregation in-process. Default. Best up to ~1M rows.
   - **Server Mode** — SQL or LINQ data source, aggregation pushed to the server. Best for 1M–100M rows.
   - **OLAP** — Microsoft Analysis Services cube. Best when data is already modeled as a cube.
   - **Asynchronous** — fetch and aggregate on a background thread (UI stays responsive).
6. **Data source type**: `DataTable` / `DataSet`, `List` (POCOs), Entity Framework / Entity Framework Core, OLE DB connection, OLAP cube, custom?
7. **Initial layout**: Which fields go in **Row** / **Column** / **Data** / **Filter** areas? (e.g., "Country in Row, Year in Column, Sales in Data".)
8. **Aggregation function**: Sum, Count, Average, Min, Max, or Custom? Default for numeric fields is Sum.
9. **Grouping intervals**: Should dates roll up to year/month/quarter? Should numeric values group into ranges?
10. **Features needed**: Drill-down, KPI, Conditional Formatting, Chart integration, Print / Export? Match references in the Navigation Guide.

> **Rule**: If the developer's answer is ambiguous or missing, ask before generating code. Do not guess.

## Component Overview

The Pivot Grid is composed of:

- **`DevExpress.Xpf.PivotGrid.PivotGridControl`** — the main control. Holds fields, a data source, and processing engine setting.
- **`DevExpress.Xpf.PivotGrid.PivotGridField`** — defines a field. Bound to a data column via `DataBinding`; positioned in an area via `Area` / `AreaIndex`; aggregated via `SummaryType`.
- **`DevExpress.Xpf.PivotGrid.FieldArea`** — enum: `RowArea`, `ColumnArea`, `DataArea`, `FilterArea`.
- **`DevExpress.Xpf.PivotGrid.DataSourceColumnBinding`** — binds a field to a data source column with optional grouping (`GroupInterval`).
- **`DevExpress.Xpf.PivotGrid.FieldGroupInterval`** — enum: `Default`, `Alphabetical`, `DateYear`, `DateMonth`, `DateDay`, `DateQuarter`, `Numeric`, etc.
- Inherited / related: `PivotGridControl.DataSource`, `Fields`, `BeginUpdate()` / `EndUpdate()`.

### XAML Namespace

The Pivot Grid uses a **different XAML namespace** from GridControl / TreeListControl:

```xml
xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
```

(Compare with `xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"` for GridControl.)

### Core Entry Point

```xaml

    

```

```csharp
using DevExpress.Xpf.PivotGrid;

private void Window_Loaded(object sender, RoutedEventArgs e) {
    pivotGridControl1.DataSource = GetSalesTable();   // DataTable or IEnumerable

    pivotGridControl1.BeginUpdate();
    AddField("Country",  FieldArea.RowArea,    "Country",       0);
    AddField("Year",     FieldArea.ColumnArea, "OrderDate",     0);
    AddField("Sales",    FieldArea.DataArea,   "ExtendedPrice", 0);
    pivotGridControl1.EndUpdate();
}

void AddField(string caption, FieldArea area, string columnName, int index) {
    var field = pivotGridControl1.Fields.Add();
    field.Caption = caption;
    field.Area = area;
    field.DataBinding = new DataSourceColumnBinding(columnName);
    field.AreaIndex = index;
}
```

`DataProcessingEngine="Optimized"` enables the new high-performance engine (default in modern versions). `BeginUpdate` / `EndUpdate` batch field changes to avoid intermediate layout recalculations.

Source: `articles/controls-and-libraries/pivot-grid/getting-started/NET-Core/lesson-1-bind-a-pivot-grid-to-an-mdb-database-net.md`.

## Documentation & Navigation Guide

### Getting Started
Refer to [references/getting-started.md](references/getting-started.md)

When you need to:
- Set up `PivotGridControl` in a new .NET 6/7/8+ WPF project
- Bind to a `DataTable` from MDB or any ADO.NET source
- Bind to a `List` of POCOs
- Create the first four fields and see a working pivot table

For .NET Framework 4.x: see [references/getting-started-dotnet-fw.md](references/getting-started-dotnet-fw.md).

### Data Binding
Refer to [references/data-binding.md](references/data-binding.md)

When you need to:
- Bind to `DataTable` / `DataSet` (ADO.NET)
- Bind to in-memory collections (`List`, `IEnumerable`)
- Bind to Entity Framework Core
- Bind to Microsoft Analysis Services (OLAP cubes)
- Use Server Mode for large data sets
- Use Asynchronous Mode for background-thread aggregation
- Use the Items Source Configuration Wizard

### Data Shaping (Aggregation, Grouping, Sorting, Filtering)
Refer to [references/data-shaping.md](references/data-shaping.md)

When you need to:
- Change the aggregation function per field (Sum, Count, Average, Min, Max, Custom)
- Group date values by year / quarter / month / day
- Group numeric values into ranges
- Sort by field value or by summary
- Filter individual fields or the entire pivot
- Compute calculated fields or window calculations

### Layout and Fields
Refer to [references/layout-and-fields.md](references/layout-and-fields.md)

When you need to:
- Understand the four areas (Row, Column, Data, Filter)
- Group fields into Field Groups (`PivotGridGroup`)
- Use the Field List / Customization Form
- Best-fit column widths

### Save and Restore Layout
Refer to [references/save-restore-layout.md](references/save-restore-layout.md)

When you need to:
- Persist field configuration / sort / filter / format conditions to XML or stream
- Save and restore collapsed/expanded state (separate API)
- Reconcile a saved layout with a control whose field set has changed (`AddNewFields` / `RemoveOldFields`)
- Handle layout version upgrades

### End-User Features
Refer to [references/end-user-features.md](references/end-user-features.md)

When you need to:
- Configure drag-and-drop of fields between areas at runtime
- Allow drill-down on data cells
- Use the Excel-style filter dropdown
- Show / hide the field list
- Configure the navigation buttons

### KPI (Key Performance Indicators)
Refer to [references/kpi.md](references/kpi.md)

When you need to:
- Display Analysis Services cube KPIs (Value / Goal / Status / Trend / Weight)
- Show traffic-light / cylinder / arrow status icons
- Customize the KPI cell template
- Render KPI graphics for non-OLAP table data sources

### Chart Integration
Refer to [references/chart-integration.md](references/chart-integration.md)

When you need to:
- Show a `ChartControl` synced to the visible pivot data
- Switch row-as-series vs column-as-series
- Limit series / point counts
- Chart only selected cells (live drill-into-chart)

### MVVM Patterns
Refer to [references/mvvm.md](references/mvvm.md)

When you need to:
- Define fields via a ViewModel collection (`FieldsSource`) instead of XAML
- Generate fields dynamically based on data schema or user choice
- Use a `DataTemplateSelector` for conditional field shapes
- Persist layout from / restore layout to the ViewModel

### Conditional Formatting
Refer to [references/conditional-formatting.md](references/conditional-formatting.md)

When you need to:
- Add data bars, color scales, icon sets, or top/bottom rules to data cells
- Apply value- or expression-based formats (`FormatCondition`)
- Scope a rule to all cells vs. a specific row × column intersection
- Let end users add and manage rules at runtime

### Appearance & Templates
Refer to [references/appearance.md](references/appearance.md)

When you need to:
- Override theme colors for cells / values / totals
- Apply a `Style` to cells, field headers, or field values
- Replace a cell's or field value's visual tree with a `DataTemplate`
- Color cells by role or value via the `CustomCellAppearance` event

### Advanced Features
Refer to [references/advanced-features.md](references/advanced-features.md)

When you need to:
- Print, preview, or export to PDF / XLSX / HTML / CSV / RTF / MHT / TXT
- A condensed overview of conditional formatting, KPI, chart integration, color customization, and MVVM — see the dedicated references above ([conditional-formatting.md](references/conditional-formatting.md), [appearance.md](references/appearance.md), [kpi.md](references/kpi.md), [chart-integration.md](references/chart-integration.md), [mvvm.md](references/mvvm.md)) for in-depth coverage

## Quick Start Example

Minimal binding to a `DataTable` of sales, with three fields (Country in Row, Year in Column, Sales in Data):

```xaml

    
        
    

```

```csharp
using DevExpress.Xpf.PivotGrid;
using System.Data;
using System.Windows;

namespace MyApp;

public partial class MainWindow : System.Windows.Window {
    public MainWindow() => InitializeComponent();

    private void Window_Loaded(object sender, RoutedEventArgs e) {
        pivotGridControl1.DataSource = SalesData.Build();

        pivotGridControl1.BeginUpdate();
        AddField("Country", FieldArea.RowArea,    "Country");
        AddField("Year",    FieldArea.ColumnArea, "OrderDate", interval: FieldGroupInterval.DateYear);
        AddField("Sales",   FieldArea.DataArea,   "Amount");
        pivotGridControl1.EndUpdate();
    }

    void AddField(string caption, FieldArea area, string columnName,
                  FieldGroupInterval interval = FieldGroupInterval.Default) {
        var field = pivotGridControl1.Fields.Add();
        field.Caption = caption;
        field.Area = area;
        field.DataBinding = new DataSourceColumnBinding(columnName) { GroupInterval = interval };
    }
}
```

### What This Does

Builds a pivot table where each row is a country, each column is a year, and each cell shows the sum of `Amount` for that Country × Year combination. The `DateYear` group interval rolls daily `OrderDate` values up to a year boundary.

## Key Properties & API Surface

### `PivotGridControl` (`DevExpress.Xpf.PivotGrid.PivotGridControl`)

| Property/Method | Type | Description |
|---|---|---|
| `DataSource` | `object` | The bound data source (`DataTable`, `IEnumerable`, `IListSource`, server-mode source, OLAP source). **Not** `ItemsSource`. |
| `DataProcessingEngine` | `DataProcessingEngine` | `Optimized` (default, recommended) or `Legacy`. |
| `Fields` | `PivotGridFieldCollection` | Collection of `PivotGridField` definitions. |
| `BeginUpdate()` / `EndUpdate()` | `void` | Batch field changes to avoid intermediate layout recalcs. |
| `EndUpdateAsync()` | `Task` | Async variant of `EndUpdate`. |
| `DataSourceChanged` | event | Raised when `DataSource` changes. |

### `PivotGridField` (`DevExpress.Xpf.PivotGrid.PivotGridField`)

| Property | Type | Description |
|---|---|---|
| `Caption` | `string` | Header text shown in the field area. |
| `Area` | `FieldArea` | `RowArea`, `ColumnArea`, `DataArea`, or `FilterArea`. |
| `AreaIndex` | `int` | Position within the area (left-to-right or top-to-bottom). Set after the field is added to `Fields`. |
| `DataBinding` | `DataBinding` | A `DataSourceColumnBinding`, `ExpressionDataBinding`, or one of the window-calculation bindings (`RunningTotalBinding`, `DifferenceBinding`, `RankBinding`, `PercentOfTotalBinding`, `MovingCalculationBinding`, `WindowExpressionBinding`). |
| `SummaryType` | `FieldSummaryType` | Aggregation function: `Sum`, `Count`, `Average`, `Min`, `Max`, `Custom`. Default `Sum`. |
| `Name` | `string` | Programmatic identifier. **Not** the key used by the `Fields[string]` indexer — that one searches by the data-source column name (`FieldName`). For lookup by `Name`, use `Fields.GetFieldByName("name")`. |

### `DataSourceColumnBinding`

| Property | Type | Description |
|---|---|---|
| `ColumnName` | `string` | Name of the data source column. |
| `GroupInterval` | `FieldGroupInterval` | `Default`, `Alphabetical`, `DateYear`, `DateMonth`, `DateDay`, `DateQuarter`, `DateWeekOfYear`, `Numeric`, etc. |
| `GroupIntervalNumericRange` | `double` | When `GroupInterval = Numeric`, the bucket width. |

### `FieldArea` Enum

| Value | Effect |
|---|---|
| `RowArea` | Field values appear as row headers (vertical list along the left). |
| `ColumnArea` | Field values appear as column headers (horizontal list along the top). |
| `DataArea` | Field's values are aggregated and shown in cells. |
| `FilterArea` | Field appears as a filter selector at the top, applied to the whole pivot. |

## Common Patterns

### Pattern 1: Bind to a DataTable (ADO.NET / OLE DB / MDB)

```csharp
using System.Data;
using System.Data.OleDb;
using DevExpress.Xpf.PivotGrid;

void LoadFromMdb() {
    var conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=NWIND.MDB");
    var adapter = new OleDbDataAdapter("SELECT * FROM SalesPerson", conn);
    var ds = new DataSet();
    adapter.Fill(ds, "SalesPerson");

    pivotGridControl1.DataSource = ds.Tables["SalesPerson"];
    // ... then AddFi

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [DevExpress](https://github.com/DevExpress)
- **Source:** [DevExpress/agent-skills](https://github.com/DevExpress/agent-skills)
- **License:** MIT
- **Homepage:** https://www.devexpress.com

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-devexpress-agent-skills-devexpress-wpf-pivot-grid
- Seller: https://agentstack.voostack.com/s/devexpress
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
