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.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
#Declaration
[Browsable(false)]
public BarManagerActionCollection HeaderAreaMenuCustomizations { get; }
#Property Value
Type | Description |
---|---|
Bar |
A Bar |
#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.
Note
The complete sample project How to Customize the Pivot Grid Context Menu is available in the DevExpress Examples repository.
?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 != null)
{
Clipboard.SetDataObject(menuInfo.CellElementData.DisplayText);
}
}
}
}
#Related GitHub Examples
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.