Skip to main content
A newer version of this page is available. .

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.v18.2.dll

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

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2205.

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

namespace WpfPivotGrid_CustomMenu
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            pivotGrid.DataSource = DataHelper.CreatePivotDataSource();
        }

        private void CopyFieldElementData_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
        {
            PivotGridFieldValueMenuInfo menuInfo = pivotGrid.GridMenu.MenuInfo as PivotGridFieldValueMenuInfo;
            if (menuInfo != null && menuInfo.FieldValueElementData != null &&
                menuInfo.FieldValueElementData.Value.ToString() != string.Empty)
            {
                Clipboard.SetDataObject(menuInfo.FieldValueElementData.Value);
            }
        }

        private void FilterFieldElementData_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
        {
            PivotGridFieldValueMenuInfo menuInfo = pivotGrid.GridMenu.MenuInfo as PivotGridFieldValueMenuInfo;
            if (menuInfo != null && menuInfo.FieldValueElementData != null &&
                menuInfo.FieldValueElementData.Value != null &&
                menuInfo.FieldValueElementData.Field != null)
            {
                PivotGridField field = menuInfo.FieldValueElementData.Field;
                object value = menuInfo.FieldValueElementData.Value;
                field.FilterValues.FilterType = FieldFilterType.Included;
                field.FilterValues.Add(value);
            }
        }

        private void CopyCellElementData_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
        {
            PivotGridCellMenuInfo menuInfo = pivotGrid.GridMenu.MenuInfo as PivotGridCellMenuInfo;
            if (menuInfo != null && menuInfo.CellElementData != null &&
                menuInfo.CellElementData.Value.ToString() != string.Empty)
            {
                Clipboard.SetDataObject(menuInfo.CellElementData.DisplayText);
            }
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references 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