PopupMenu PopupMenu PopupMenu PopupMenu PopupMenu Class


Represents a context menu.

public : sealed class PopupMenu : IPopupMenu
struct winrt::Windows::UI::Popups::PopupMenu : IPopupMenu
public sealed class PopupMenu : IPopupMenu
Public NotInheritable Class PopupMenu Implements IPopupMenu
var popupMenu = new popupMenu();
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


Provide users with a context menu by adding an event listener for the "contextmenu" 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);

To customize the context menu, call preventDefault on the event to suppress the default, and then create a new, empty context menu menu as shown in the Context menu sample.

e.preventDefault(); // Prevent the default context menu.
var menu = new Windows.UI.Popups.PopupMenu();


context menu can show a maximum of six commands. This limit helps to ensure that the context menu remains uncluttered, usable, and directly relevant to users.

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.


: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).


PopupMenu() PopupMenu() PopupMenu() PopupMenu() PopupMenu()

Creates a new instance of the PopupMenu class.


Commands Commands Commands Commands Commands

Gets the commands for the context menu.


ShowAsync(Point) ShowAsync(Point) ShowAsync(Point) ShowAsync(Point) ShowAsync(Point)

Shows the context menu at the specified client coordinates.

ShowForSelectionAsync(Rect) ShowForSelectionAsync(Rect) ShowForSelectionAsync(Rect) ShowForSelectionAsync(Rect) ShowForSelectionAsync(Rect)

Shows the context menu above the specified selection.

ShowForSelectionAsync(Rect, Placement) ShowForSelectionAsync(Rect, Placement) ShowForSelectionAsync(Rect, Placement) ShowForSelectionAsync(Rect, Placement) ShowForSelectionAsync(Rect, Placement)

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

See Also