PopupMenuShowingEventArgs.Customizations Property
Provides access to a collection of customizations of the popup menu.
Namespace: DevExpress.Xpf.RichEdit
Assembly: DevExpress.Xpf.RichEdit.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
BarManagerActionCollection | A BarManagerActionCollection object that is the collection of actions that manipulate a context menu. |
Remarks
The Customizations property enables you to add and remove menu items.
Example
This example demonstrates how to customize the SpreadsheetControl’s context menu - remove the existing menu items and add new items.
Handle the SpreadsheetControl.PopupMenuShowing event. Use the PopupMenuShowingEventArgs.MenuType property to determine the visual element for which the popup menu is invoked.
To remove a menu item, create the RemoveSpreadsheetCommandAction object, set its ID to the ID of the command to remove and add that object to the PopupMenuShowingEventArgs.Customizations collection.
To add a new menu item, create a new BarButtonItem and add it to the PopupMenuShowingEventArgs.Customizations collection.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-the-popup-menu-of-the-wpf-spreadsheet-control-e5147.
<dxb:BarManager x:Name="barManager1" ToolbarGlyphSize="Small">
<dxb:BarManager.Items>
<dxb:BarButtonItem
x:Name="customNewFile"
Command="{Binding FileNew, Mode=OneTime, Source={StaticResource commands}}"
Content="Custom Create New File" />
<dxb:BarButtonItem
x:Name="customMergeCells"
Command="{Binding EditingMergeAndCenterCells, Mode=OneTime, Source={StaticResource commands}}"
Content="Custom Merge Cells" />
</dxb:BarManager.Items>
<Grid>
<dxsps:SpreadsheetControl
x:Name="spreadsheetControl1"
BarManager="{Binding ElementName=barManager1, Mode=OneTime}"
PopupMenuShowing="SpreadsheetControlPopupMenuShowing">
<dxsps:SpreadsheetControl.MenuCustomizations>
<dxsps:SpreadsheetMenuCustomization MenuType="Cell">
<dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="0">
<dxb:BarButtonItemLink.BarItemName>
customMergeCells
</dxb:BarButtonItemLink.BarItemName>
</dxb:BarButtonItemLink>
</dxsps:SpreadsheetMenuCustomization>
<dxsps:SpreadsheetMenuCustomization>
<dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="1">
<dxb:BarButtonItemLink.BarItemName>
customNewFile
</dxb:BarButtonItemLink.BarItemName>
</dxb:BarButtonItemLink>
</dxsps:SpreadsheetMenuCustomization>
<dxsps:SpreadsheetMenuCustomization>
<dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="2" />
</dxsps:SpreadsheetMenuCustomization>
<dxsps:SpreadsheetMenuCustomization MenuType="ColumnHeading">
<dxsps:RemoveSpreadsheetCommandAction
Id="{x:Static dxspscore:SpreadsheetCommandId.HideColumnsContextMenuItem}" />
<dxsps:RemoveSpreadsheetCommandAction
Id="{x:Static dxspscore:SpreadsheetCommandId.UnhideColumnsContextMenuItem}" />
</dxsps:SpreadsheetMenuCustomization>
</dxsps:SpreadsheetControl.MenuCustomizations>
</dxsps:SpreadsheetControl>
</Grid>
</dxb:BarManager>