Back to Devexpress

DataSourceColumnBinding Class

wpf-devexpress-dot-xpf-dot-pivotgrid-4248320c.md

latest8.4 KB
Original Source

DataSourceColumnBinding Class

Defines a data binding to a data source column.

Namespace : DevExpress.Xpf.PivotGrid

Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

csharp
public class DataSourceColumnBinding :
    DataBinding
vb
Public Class DataSourceColumnBinding
    Inherits DataBinding

Remarks

Pivot Grid uses the Binding API to bind Pivot Grid’s fields to data. DataSourceColumnBinding allows you to bind a field to a data source column.

You can use DataSourceColumnBinding in Optimized, Server, and OLAP data processing modes.

Examples

Optimized and Server Modes

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>

OLAP mode

Follow the steps below to bind a Pivot Grid’s field to a measure or dimension in code:

  1. Create a DataSourceColumnBinding instance.

  2. Specify the DataSourceColumnBinding.ColumnName property. ColumnName must specify the full name of the bound measure or dimension.

  3. Assign the DataSourceColumnBinding object to the PivotGridField.DataBinding property.

View Example: Pivot Grid for WPF - Bind a PivotGrid to an OLAP Cube

The following code snippet illustrates how to create the fieldMeasuresInternetSalesAmount field and bind it to the Internet Sales Amount measure:

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

namespace HowToBindOLAP {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent(); 
         }
         private void Window_Loaded(object sender, RoutedEventArgs e) {
           // ...
           PivotGridField fieldMeasuresInternetSalesAmount = 
                new PivotGridField("[Measures].[Internet Sales Amount]", FieldArea.DataArea);
            fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount";
            pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount); 
         }
    }
}
vb
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid

Namespace HowToBindOLAP
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()
        End Sub
         Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
           ' ...
           Dim fieldMeasuresInternetSalesAmount As New PivotGridField("[Measures].[Internet Sales Amount]", FieldArea.DataArea)
            fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount"
            pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount)
         End Sub
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSourceColumnBinding class.

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.

wpf-pivotgrid-how-to-display-underlying-data-asynchronously/CS/WpfDrillDownDataSourceExample/MainWindow.xaml#L39

xml
<dxpg:PivotGridField.DataBinding>
    <dxpg:DataSourceColumnBinding ColumnName="ExtendedPrice"/>
</dxpg:PivotGridField.DataBinding>

wpf-pivotgrid-how-to-display-underlying-data/CS/WpfDrillDownDataSourceExample/MainWindow.xaml#L38

xml
<dxpg:PivotGridField.DataBinding>
    <dxpg:DataSourceColumnBinding ColumnName="ExtendedPrice"/>
</dxpg:PivotGridField.DataBinding>

wpf-pivot-grid-apply-format-conditions-to-data-cells/CS/WpfPivotGridConditionalFormatting/MainWindow.xaml#L41

xml
<dxpg:PivotGridField.DataBinding>
    <dxpg:DataSourceColumnBinding ColumnName="Country"/>
</dxpg:PivotGridField.DataBinding>

wpf-pivot-grid-obtain-underlying-data/CS/ObtainUnderlyingData/MainWindow.xaml#L65

xml
<dxpg:PivotGridField.DataBinding>
    <dxpg:DataSourceColumnBinding ColumnName="Country"/>
</dxpg:PivotGridField.DataBinding>

wpf-pivot-grid-add-custom-field-values-rows-columns-not-present-in-datasource/CS/WpfApplication1/MainWindow.xaml#L20

xml
<dxpg:PivotGridField.DataBinding>
    <dxpg:DataSourceColumnBinding ColumnName="Value"/>
</dxpg:PivotGridField.DataBinding>

Inheritance

Object DispatcherObject DependencyObject ContentElement FrameworkContentElement DXFrameworkContentElement DataBinding DataSourceColumnBinding

See Also

DataSourceColumnBinding Members

Optimized Calculation Engine

Bind Pivot Grid Fields to Data Columns

DevExpress.Xpf.PivotGrid Namespace