PopupMenu.ShowForSelectionAsync Method (Rect, Placement)

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

Syntax

public:
IAsyncOperation<IUICommand^ >^ ShowForSelectionAsync(
         Rect selection,
         Placement preferredPlacement
)  

Parameters

selection
Type: Rect 

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.

preferredPlacement
Type: Placement 

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.

Return value

Type: IAsyncOperation<IUICommand^ > 

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 on the Microsoft Store app sample home page.

Requirements

Namespace: Windows.UI.Popups

Metadata: windows.winmd

See also

Reference

PopupMenu Class

PopupMenu Members

Windows.UI.Popups Namespace