Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 3.42 KB

popupmenu_showforselectionasync_655080999.md

File metadata and controls

47 lines (29 loc) · 3.42 KB
-api-id -api-type
M:Windows.UI.Popups.PopupMenu.ShowForSelectionAsync(Windows.Foundation.Rect,Windows.UI.Popups.Placement)
winrt method

Windows.UI.Popups.PopupMenu.ShowForSelectionAsync

-description

Shows the context menu in the preferred placement relative to the specified selection.

-parameters

-param selection

The coordinates (in DIPs) of the selected rectangle, relative to the window.

Note

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

-param preferredPlacement

The preferred placement of the context menu relative to the selection rectangle.

The context menu is positioned in the preferredPlacement if the menu fits in the window and does not cover the selection. If the context menu does not fit in the preferred placement, another placement that does not cover the selection is used. If the context menu does not fit anywhere else, a placement that partially or wholly covers the selection is used.

-returns

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

If no command is invoked, ShowForSelectionAsync returns null.

-remarks

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

-examples

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-jsselectionrect_js]

-see-also

Adding context menus, Context menu sample, Guidelines and checklist for , IUICommand, oncontextmenu, Rect, ShowForSelectionAsync(Rect), UICommand