IContextMenuItemCollection Interface
A collection of root-level or nested items of the context menu in the Rich Text Editor.
Namespace: DevExpress.Blazor.Office
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public interface IContextMenuItemCollection :
IEnumerable<IContextMenuItem>,
IEnumerable
Related API Members
The following members return IContextMenuItemCollection objects:
Remarks
Use the IContextMenuItemCollection
interface members to perform the following operations:
- Access root-level or nested items
- Add default or custom items to the main menu or its sub-menus.
- Remove individual or all items from a collection
- Convert an item collection into a flattened collection
- Get information about the number of items and their positions in item collections
The following code snippet operates with item collections in the CustomizeContextMenu event handler:
<DxRichEdit CustomizeContextMenu=OnCustomizeContextMenu />
@code {
void OnCustomizeContextMenu(IContextMenuItemCollection items) {
// Inserts a custom item at the first position in the item collection
var searchItem = items.AddCustomItem(0, "Google Search...", ...);
var openHyperlinkItem = items[RichEditContextMenuItemNames.OpenHyperlink];
openHyperlinkItem.BeginGroup = false;
// Gets the built-in item's position in the item collection
var index = items.IndexOf(openHyperlinkItem);
// Inserts a custom item at the specified position in the main menu's item collection
var showURLItem = items.AddCustomItem(index, "Show URL", ...);
showURLItem.BeginGroup = true;
// Removes built-in items from the item collection
items.Remove(RichEditContextMenuItemNames.CutSelection);
items.Remove(RichEditContextMenuItemNames.CopySelection);
items.Remove(RichEditContextMenuItemNames.Paste);
// Inserts a custom item at the second position in the item collection
var clipboardItem = items.AddCustomItem(1, "Clipboard");
clipboardItem.BeginGroup = true;
// Adds default items to the item collection of the inserted item
clipboardItem.Items.Add(RichEditContextMenuItemNames.CutSelection);
clipboardItem.Items.Add(RichEditContextMenuItemNames.CopySelection);
clipboardItem.Items.Add(RichEditContextMenuItemNames.Paste);
}
}
See Also