Skip to main content
All docs
V26.1
  • How to Customize a Context Menu with the PopupMenuShowing Event

    • 5 minutes to read

    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>