Bind Context Menu Events in Blazor ContextMenu Component

18 Feb 20221 minute to read

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" TValue="MenuItem">
        <MenuItem Text="Cut"></MenuItem>
        <MenuItem Text="Copy"></MenuItem>
        <MenuItem Text="Paste"></MenuItem>
    <MenuEvents TValue="MenuItem" ItemSelected="@selectedHandler"></MenuEvents>

@code {
    public MenuItem SelectedItem;
    // Triggers when the item is selected
    private void selectedHandler(MenuEventArgs<MenuItem> args) {
        SelectedItem = args.Item;

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

Binding Blazor ContextMenu Events