PopupMenu.ShowAsync(Point) PopupMenu.ShowAsync(Point) PopupMenu.ShowAsync(Point) PopupMenu.ShowAsync(Point) PopupMenu.ShowAsync(Point) Method


Shows the context menu at the specified client coordinates.

public : IAsyncOperation<IUICommand> ShowAsync(Point invocationPoint)
IAsyncOperation<IUICommand> ShowAsync(Point invocationPoint) const;
public IAsyncOperation<IUICommand> ShowAsync(Point invocationPoint)
Public Function ShowAsync(invocationPoint As Point) As IAsyncOperation(Of IUICommand)
Windows.UI.Popups.PopupMenu.showAsync(invocationPoint).done( /* Your success and error handlers */ );


Point Point Point

The coordinates (in DIPs), relative to the window, of the user's finger or mouse pointer when the oncontextmenu event fired. The menu is placed above and centered on this point.


For VB, C#, and C++, this window is the CoreWindow associated with the thread that is calling the context menu.


A IUICommand object that represents the context menu command that was invoked by the user, after the ShowAsync call completes.

If no command is invoked, ShowAsync returns null.


Before you can show a context menu, you must add an event listener for the oncontextmenu event. For example, the Context menu sample listens for the event on specific HTML elements, and then calls the scenario1AttachmentHandler function.

document.getElementById("attachment").addEventListener("contextmenu", attachmentHandler, false);
menu.commands.append(new Windows.UI.Popups.UICommand("Save attachment", onSaveAttachment));

// We don't want to obscure content, so pass in the position representing the selection area.
// We registered command callbacks; no need to handle the menu completion event
menu.showAsync(pageToWinRT(e.pageX, e.pageY)).then(function (invokedCommand) {
    if (invokedCommand === null) {
        // The command is null if no command was invoked.
        WinJS.log && WinJS.log("Context menu dismissed", "sample", "status");

Additionally, make sure you check that a command was invoked and process that case as appropriate for your app. If the UICommand that is invoked has a callback function (onSaveAttachment in the example), the callback function will be executed. Otherwise, you may need to use UICommand.Id to identify and process the invoked command.


You can see complete code examples that demonstrate how to create and customize context menu in the Context menu sample on the sample home page.

See also