Back to Devexpress

Bind Pivot Grid Fields to Data Columns

wpf-401387-controls-and-libraries-pivot-grid-binding-to-data-in-memory-mode-optimized-mode-bind-pivot-grid-fields-to-data-columns.md

latest1.6 KB
Original Source

Bind Pivot Grid Fields to Data Columns

  • Aug 10, 2023

Pivot Grid uses the Binding API to bind Pivot Grid fields to data. This topic describes how to use the Binding API to bind a Pivot Grid field to a data source column when the Pivot Grid uses the Optimized data processing engine.

Important

You cannot bind the Pivot Grid to data at design time in .NET 5+ projects.

Follow the steps below to bind a Pivot Grid field to a data source column in code:

  1. Create a DataSourceColumnBinding instance.
  2. Set the DataSourceColumnBinding.ColumnName property to the name of a data source column.
  3. Assign the DataSourceColumnBinding object to the PivotGridField.DataBinding property.

The following code snippet illustrates the Pivot Grid’s Product Sales field bound to the Extended Price source column:

xaml
<dxpg:PivotGridControl>
    <dxpg:PivotGridControl.Fields>
      <dxpg:PivotGridField
          Area="DataArea"
          AreaIndex="5"
          Caption="Product Sales"
          CellFormat="C"
          Name="fieldSales">
          <dxpg:PivotGridField.DataBinding>
              <dxpg:DataSourceColumnBinding ColumnName="Extended Price" />
          </dxpg:PivotGridField.DataBinding>
        </dxpg:PivotGridField>
      </dxpg:PivotGridControl.Fields>
</dxpg:PivotGridControl>

See Also

DataSourceColumnBinding