Skip to main content

PivotGridControl.PopupMenuShowing Event

Allows you to customize the context menus.

Namespace: DevExpress.Xpf.PivotGrid

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

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public event PopupMenuShowingEventHandler PopupMenuShowing

Event Data

The PopupMenuShowing event's data class is PopupMenuShowingEventArgs. The following properties provide information specific to this event:

Property Description
Customizations Allows you to customize the context menu by adding new menu items or removing existing items.
Handled Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
Items Gets a collection of items contained within the context menu.
MenuType Gets what kind of pivot grid element invokes the menu.
OriginalSource Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEvent Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
Source Gets the PivotGridControl that raised the event.
TargetElement Gets the UI element for which the context menu is shown.

The event data class exposes the following methods:

Method Description
GetCellInfo() Returns information about the cell for which the menu is invoked.
GetFieldInfo() Returns information about the field for whose header the menu is invoked.
GetFieldValueInfo() Returns information about the field value for which the menu is invoked.
InvokeEventHandler(Delegate, Object) When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object) When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The PopupMenuShowing event occurs when an end-user invokes a context menu.

Use the event parameter’s PopupMenuShowingEventArgs.Customizations property to add new and remove existing menu items. This property provides access to a collection of actions that allow you to customize the context menu. To learn more, see Context Menus, Items and Links and Bar Actions.

To determine for what kind of pivot grid element (a cell, a field value, a field header or the field header area) the menu is invoked, use the PopupMenuShowingEventArgs.MenuType property. To gwt the actual visual element for which the menu is invoked, use the PopupMenuShowingEventArgs.TargetElement property.

Use the following methods to get more information about the visual element.

PopupMenuShowingEventArgs.GetCellInfo

Returns information about the cell for which the menu is invoked.

PopupMenuShowingEventArgs.GetFieldValueInfo

Returns information about the field value for which the menu is invoked.

PopupMenuShowingEventArgs.GetFieldInfo

Returns information about the field for whose header the menu is invoked.

Example

This example demonstrates how to use the PivotGridControl.PopupMenuShowing event to add custom items to the built-in context menu.

pivotgrid-popupmenushowing-event

The event is handled automatically if the field’s AllowFieldSummaryTypeChanging or AllowFieldSummaryDisplayTypeChanging attached properties are true. The properties are defined in the HeaderMenuHelper class.

<Window  x:Class="HeaderMenuCustomizationExample.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:HeaderMenuCustomizationExample"
         Title="Data Header Context Menu Customization" Height="450" Width="800"
         Loaded="Window_Loaded">
    <Grid>
        <dxpg:PivotGridControl Name="pivotGridControl1"
                               local:HeaderMenuHelper.AllowPopupMenuCustomization="True"
                               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" Name="fieldValue"
                                     local:HeaderMenuHelper.AllowFieldSummaryTypeChanging="True"
                                     local:HeaderMenuHelper.AllowFieldSummaryDisplayTypeChanging="True" />
                <dxpg:PivotGridField Area="DataArea" FieldName="Target" Name="fieldTarget"
                                     local:HeaderMenuHelper.AllowFieldSummaryTypeChanging="True"
                                     local:HeaderMenuHelper.AllowFieldSummaryDisplayTypeChanging="True" />
            </dxpg:PivotGridControl.Fields>

        </dxpg:PivotGridControl>
    </Grid>
</Window>

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

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