Skip to main content
A newer version of this page is available. .

DxContextMenu.ShowAsync(Double, Double) Method

Displays the Context Menu at the specified location.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v22.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task ShowAsync(
    double x,
    double y
)

Parameters

Name Type Description
x Double

Specifies the location’s X coordinate.

y Double

Specifies the location’s Y coordinate.

Returns

Type Description
Task

An asynchronous operation that displays the Context Menu.

Remarks

Call this method to show the Context Menu at the specified coordinates on a browser window (x,y). To specify the code that should be executed when the Context Menu is displayed, handle the Shown event.

The following example displays the Context Menu with a 5-pixel shift to the right and a 2-pixel shift upward from the click position:

<div style="height: 200px;"  
     @oncontextmenu="((e) => ContextMenu.ShowAsync(e.PageX + 5, e.PageY - 2))" 
     @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;
}

Context menu shift

To show the Context Menu at a mouse event’s coordinates (for example, the user’s right-click position), use the ShowAsync(MouseEventArgs) method. To hide the Context Menu, call the HideAsync() method.

Run Demo: Context Menu

See Also