Skip to main content

PivotGridControl.HeaderAreaMenuCustomizations Property

Allows you to customize the context menu, invoked when right-clicking the header area, by adding new menu items or removing existing items.

Namespace: DevExpress.Xpf.PivotGrid

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

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

[Browsable(false)]
public BarManagerActionCollection HeaderAreaMenuCustomizations { get; }

Property Value

Type Description
BarManagerActionCollection

A BarManagerActionCollection object, representing a collection of actions that manipulate menu items.

Remarks

To learn more, see Context Menus, Items and Links and Bar Actions.

Example

This example shows how to modify context menu for the Field, Data and Header areas in the PivotGridControl.

  • Field Value context menu contains two new items. One command enables the end-user to exclude all fields but the one which is hovered over. Another command copies the filed name to the clipboard.
  • Data Area context menu contains a command which enables the end-user to copy cell content to the clipboard.
  • Field Header context menu context menu is modified to remove a command which reorders fields.
  • Header Area context menu is modified to remove all built-in commands and add a drop-down menu with a single item which enables the end-user to show/hide column grand totals.

Custom Context Menu for PivotGrid Areas

Note

The complete sample project How to Customize the Pivot Grid Context Menu is available in the DevExpress Examples repository.

?<Window
    x:Class="WpfPivotGrid_CustomMenu.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
    xmlns:local="clr-namespace:WpfPivotGrid_CustomMenu"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    Width="800"
    Height="500"
    mc:Ignorable="d"
    Loaded="Window_Loaded"
    Title="MainWindow">

    <Grid>
        <dxb:BarManager Name="barManager">
            <dxb:BarManager.Items>
                <dxb:BarCheckItem Name="ShowColumnGrandTotals"
                              IsChecked="{Binding ElementName=pivotGrid, Path=ShowColumnGrandTotals, Mode=TwoWay}"
                              Content="Show Column Grand Totals" />
            </dxb:BarManager.Items>
            <dxpg:PivotGridControl Name="pivotGrid" RowTreeWidth="130">
                <dxpg:PivotGridControl.Fields>
                    <dxpg:PivotGridField Area="RowArea" FieldName="Name" />
                    <dxpg:PivotGridField Area="RowArea" FieldName="Owner" />
                    <dxpg:PivotGridField Area="ColumnArea" FieldName="Type" />
                    <dxpg:PivotGridField Area="DataArea" FieldName="Value" />
                    <dxpg:PivotGridField Area="DataArea" FieldName="Target" />
                </dxpg:PivotGridControl.Fields>
                <dxpg:PivotGridControl.FieldValueMenuCustomizations>
                    <dxb:BarButtonItem Name="CopyFieldElementData" Content="Copy Field Element Value" 
                                           ItemClick="CopyFieldElementData_ItemClick"/>
                    <dxb:BarButtonItem Name="FilterFieldElementData" Content="Filter By Field Element" 
                                           ItemClick="FilterFieldElementData_ItemClick"/>
                </dxpg:PivotGridControl.FieldValueMenuCustomizations>
                <dxpg:PivotGridControl.CellMenuCustomizations>
                    <dxb:BarButtonItem Name="CopyCellElementData" Content="Copy Cell Data" 
                                           ItemClick="CopyCellElementData_ItemClick"/>
                </dxpg:PivotGridControl.CellMenuCustomizations>
                <dxpg:PivotGridControl.HeaderMenuCustomizations>
                    <dxb:RemoveBarItemAndLinkAction 
                    ItemName="{x:Static dxpg:DefaultMenuItemNames.FieldOrder}" />
                </dxpg:PivotGridControl.HeaderMenuCustomizations>
                <dxpg:PivotGridControl.HeaderAreaMenuCustomizations >
                    <dxb:BarItemSeparator/>
                    <dxb:BarSubItem Content="Totals">
                        <dxb:BarSubItem.ItemLinks>
                            <dxb:BarCheckItemLink BarItemName="ShowColumnGrandTotals" />
                        </dxb:BarSubItem.ItemLinks>
                    </dxb:BarSubItem>
                    <dxb:RemoveBarItemAndLinkAction ItemName="ItemShowPrefilter" />
                    <dxb:RemoveBarItemAndLinkAction ItemName="ItemHidePrefilter" />
                    <dxb:RemoveBarItemAndLinkAction ItemName="ItemRefreshData" />
                    <dxb:RemoveBarItemAndLinkAction ItemName="ItemShowFieldList" />
                </dxpg:PivotGridControl.HeaderAreaMenuCustomizations>
            </dxpg:PivotGridControl>
        </dxb:BarManager>
    </Grid>

</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HeaderAreaMenuCustomizations 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.

See Also