Search results

Bind Context Menu Events in Blazor ContextMenu component

To bind the menu event in the context menu ItemSelected is used and the event is triggered when the item in the context menu is selected.

@using Syncfusion.Blazor.Navigations

<div id="target">Right click/Touch hold to open the ContextMenu </div>
<SfContextMenu Target="#target" Items="@MenuItems">
    <ContextMenuEvents ItemSelected="@select"></ContextMenuEvents>

@code {
    public MenuItemModel SelectedItem;
    public List<MenuItem> MenuItems = new List <MenuItem>
        new MenuItem{ Text = "Cut" },
        new MenuItem{ Text = "Copy" },
        new MenuItem{ Text = "Paste" }

    private void select(MenuEventArgs args) {
    this.SelectedItem = args.Item; // Triggers when item is selected

    #target {
        border: 1px dashed;
        height: 150px;
        padding: 10px;
        position: relative;
        text-align: justify;
        color: gray;
        user-select: none;

Output be like

Context Menu Sample