Skip to main content

DxContextMenu.ShowAsync(MouseEventArgs) Method

Displays the Context Menu according to a mouse event’s coordinates.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task ShowAsync(
    MouseEventArgs e
)

Parameters

Name Type Description
e MouseEventArgs

The Blazor’s built-in MouseEventArgs event arguments.

Returns

Type Description
Task

The task that is completed when the context menu is displayed.

Remarks

Call this method to show the Context Menu at a mouse event’s coordinates (for example, the user’s right-click position). To specify the code that should be executed when the Context Menu is displayed, handle the Shown event.

Note

To display the Context Menu at the specified location (x,y), use the ShowAsync(Double, Double) method. To hide a Context Menu, call the HideAsync() method.

<div style="height: 200px;"  
     @oncontextmenu="((e) => ContextMenu.ShowAsync(e))" 
     @oncontextmenu:preventDefault>
    <span style="font-weight: 600">RIGHT-CLICK TO SHOW THE CONTEXT MENU</span>
</div>

<DxContextMenu @ref="@ContextMenu">
    <Items>
        <DxContextMenuItem Text="Copy" />
        <DxContextMenuItem Text="Cut" />
        <DxContextMenuItem Text="Remove" />
    </Items>
</DxContextMenu>

@code {
    DxContextMenu ContextMenu { get; set; }
}

Run Demo: Context Menu

See Also