Search results

Open and close Context Menu in Blazor ContextMenu component

Open and close the Context Menu manually whenever required by using the open and close methods. In the following sample, to open the Context Menu at specified position the Open method is used with X and Y coordinates and to close Context Menu Close method can be used.

@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Buttons

<div id="target">
    <SfContextMenu Target="#target" Items="@MenuItems" @ref="ContextMenuObj"></SfContextMenu>
    <SfButton CssClass="e-btn" OnClick="open">Open ContextMenu</SfButton>

@code {
    SfContextMenu<MenuItem> ContextMenuObj;
    public List<MenuItem> MenuItems = new List<MenuItem>{
        new MenuItem { Text = "Cut" },
        new MenuItem { Text = "Copy" },
        new MenuItem { Text = "Paste" }
    private void open()
        ContextMenuObj.Open(280, 110);

Output be like

Context Menu Sample