Back to Devexpress

PivotGridField.Area Property

wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridfield-fac47236.md

latest15.9 KB
Original Source

PivotGridField.Area Property

Gets or sets the area in which the field is displayed. This is a dependency property.

Namespace : DevExpress.Xpf.PivotGrid

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

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

csharp
public FieldArea Area { get; set; }
vb
Public Property Area As FieldArea

Property Value

TypeDescription
FieldArea

A FieldArea value that specifies the area in which the field is displayed.

|

Available values:

NameDescription
RowArea

Corresponds to the row header area.

| | ColumnArea |

Corresponds to the column header area.

| | FilterArea |

Corresponds to the filter header area.

| | DataArea |

Corresponds to the data header area.

|

Remarks

A field can be placed in one of four areas: Filter Header Area, Column Header Area, Row Header Area or Data Header Area. The Area property specifies the area in which the field is displayed. The field can also be positioned using the PivotGridField.SetAreaPosition method. To get the field’s position among the other fields within the same area, use the PivotGridField.AreaIndex property.

The PivotGridField.AllowedAreas property specifies in which areas the field can be located. To obtain whether the field can be displayed in a particular area, use the PivotGridField.IsAreaAllowed property.

Dragging a field from one area to another automatically changes the Area property value, and vice versa. Before the field location is changed, PivotGridControl fires the PivotGridControl.FieldAreaChanging event, allowing you to cancel the action. After the location has been changed, the PivotGridControl.FieldAreaChanged event is fired.

Multiple fields can be combined into a group via the PivotGridControl.Groups property. These fields cannot be separated and are always dragged together. To move a group to a specific area or to a new position within the current area, use the Area and PivotGridField.AreaIndex properties of the first field in the group. Modifying the Area and AreaIndex properties for the second and subsequent fields in the group is ignored.

Example

The following example demonstrates how to bind the PivotGridControl to a “SalesPerson” view in the nwind.mdb database, which is shipped with the installation. The control will be used to analyse sales per country, customers, product categories and years.

The following steps were used to created this example:

  1. A typed dataset is created from the database at design time.
  2. Instances of SalesPersonDataTable and SalesPersonTableAdapter objects are created.
  3. The PivotGridControl is bound to the SalesPersonDataTable instance via the PivotGridControl.DataSource property.
  4. The table is filled with data in the Window_Loaded event handler.

The pivot grid fields that will represent data source fields are created in XAML markup. They are positioned within appropriate areas to analyze the data in the way you want.

Note that if you want to see an example of how to programmatically add pivot grid fields, please refer to the How to: Bind a PivotGrid to an MS Access Database Programmatically example.

xaml
<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"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Grid>
        <dxpg:PivotGridControl Name="pivotGridControl1" DataProcessingEngine="Optimized">
            <dxpg:PivotGridControl.Fields>
                <dxpg:PivotGridField Name="fieldCountry" Area="RowArea">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Country"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldCustomer" Area="RowArea"
                                     Caption="Customer">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Sales Person"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldYear" Area="ColumnArea" Caption="Year" >
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateYear"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldCategoryName" Area="ColumnArea" Caption="Product Category">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="CategoryName"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldProductName" Area="FilterArea" Caption="Product Name">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="ProductName"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldExtendedPrice" Area="DataArea" CellFormat="c0">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Extended Price"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
            </dxpg:PivotGridControl.Fields>
        </dxpg:PivotGridControl>
    </Grid>
</Window>
cs
using System.Data;
using System.Data.OleDb;
using System.Windows;
using DevExpress.Xpf.PivotGrid;
using HowToBindToMDB.NwindDataSetTableAdapters;

namespace HowToBindToMDB {
    public partial class MainWindow : Window {
        NwindDataSet.SalesPersonDataTable salesPersonDataTable = 
            new NwindDataSet.SalesPersonDataTable();
        SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();

        public MainWindow() {
            InitializeComponent();
            pivotGridControl1.DataSource = salesPersonDataTable;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            salesPersonDataAdapter.Fill(salesPersonDataTable);
        }
    }
}
vb
Imports System.Windows
Imports HowToBindToMDB.NwindDataSetTableAdapters

Namespace HowToBindToMDB

    Public Partial Class MainWindow
        Inherits Window

        Private salesPersonDataTable As NwindDataSet.SalesPersonDataTable = New NwindDataSet.SalesPersonDataTable()

        Private salesPersonDataAdapter As SalesPersonTableAdapter = New SalesPersonTableAdapter()

        Public Sub New()
            Me.InitializeComponent()
            Me.pivotGridControl1.DataSource = salesPersonDataTable
        End Sub

        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            salesPersonDataAdapter.Fill(salesPersonDataTable)
        End Sub
    End Class
End Namespace

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

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-customize-filter-drop-down/CS/WpfPivotCustomFilterDropDownExample/MainWindow.xaml#L48

xml
<dxpg:PivotGridField
    Area="DataArea"
    Caption="Product Sales"

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

xml
x:Name="fieldSales"
Area="DataArea"
Caption="Product Sales">

wpf-pivotgrid-hide-column-totals/CS/HowToBindToMDB/MainWindow.xaml#L13

xml
<dxpg:PivotGridControl.Fields>
    <dxpg:PivotGridField Name="fieldOrderID" Area="RowArea">
        <dxpg:PivotGridField.DataBinding>

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

xml
x:Name="fieldSales"
Area="DataArea"
Caption="Product Sales">

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

xml
<dxpg:PivotGridControl.Fields>
    <dxpg:PivotGridField Area="RowArea"
                         Name="fieldCountry" AreaIndex="0">

wpf-pivot-grid-show-top-n-values-in-context-menu/CS/ContextMenuToShowTopN_Example/MainWindow.xaml.cs#L39

csharp
pivotGridControl1.RetrieveFields();
pivotGridControl1.Fields["Sales Person"].Area = FieldArea.RowArea;
pivotGridControl1.Fields["CategoryName"].Area = FieldArea.RowArea;

wpf-pivot-grid-bind-to-an-olap-cube-net6/CS/HowToBindOLAP/MainWindow.xaml.cs#L23

csharp
fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount";
fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea;
pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount);

wpf-pivot-grid-bind-to-an-mdb-database/CS/HowToBindToMDB/MainWindow.xaml.cs#L47

csharp
field.Caption = caption;
field.Area = area;
field.DataBinding = new DataSourceColumnBinding(columnName);

wpf-pivot-grid-hide-specific-columns-and-row/CS/WpfApp/Data.cs#L29

csharp
foreach (PivotGridField field in pivot.Fields) {
    field.AllowedAreas = GetAllowedArea(field.Area);
}

wpf-pivotgrid-hide-column-totals/CS/HowToBindToMDB/MainWindow.xaml.cs#L37

csharp
field.Caption = caption;
field.Area = area;
field.DataBinding = new DataSourceColumnBinding(columnName);

wpf-pivot-grid-show-top-n-values-in-context-menu/VB/ContextMenuToShowTopN_Example/MainWindow.xaml.vb#L36

vb
pivotGridControl1.RetrieveFields()
pivotGridControl1.Fields("Sales Person").Area = FieldArea.RowArea
pivotGridControl1.Fields("CategoryName").Area = FieldArea.RowArea

wpf-pivot-grid-bind-to-an-olap-cube-net6/VB/HowToBindOLAP/MainWindow.xaml.vb#L21

vb
fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount"
fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea
pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount)

wpf-pivot-grid-bind-to-an-mdb-database/VB/HowToBindToMDB/MainWindow.xaml.vb#L42

vb
field.Caption = caption
field.Area = area
field.DataBinding = New DataSourceColumnBinding(columnName)

wpf-pivot-grid-hide-specific-columns-and-row/VB/WpfApp/Data.vb#L32

vb
For Each field As PivotGridField In pivot.Fields
    field.AllowedAreas = GetAllowedArea(field.Area)
Next field

wpf-pivot-grid-split-field-value-cells/VB/Data.vb#L40

vb
For Each field As PivotGridField In pivot.Fields
    field.AllowedAreas = GetAllowedArea(field.Area)
Next

See Also

AllowedAreas

AreaIndex

SetAreaPosition(FieldArea, Int32)

PivotGridField Class

PivotGridField Members

DevExpress.Xpf.PivotGrid Namespace