Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

C#
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.

razor
<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