-api-id | -api-type |
---|---|
M:Windows.UI.Popups.PopupMenu.ShowAsync(Windows.Foundation.Point) |
winrt method |
Shows the context menu at the specified client coordinates.
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.
Note
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.
You can see complete code examples that demonstrate how to create and customize context menus in the Context menu sample.
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.
[!code-jsaddcontextmenueventlistener_js]
[!code-jsaddandshowwithhandlers_js]
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.
Adding context menus, Context menu sample, Guidelines and checklist for , IUICommand, oncontextmenu, Point, PopupMenu.Commands, UICommand