PopupMenu.Commands Property


Gets the commands for the context menu.

 property IVector<IUICommand ^> ^ Commands { IVector<IUICommand ^> ^ get(); };
IVector<IUICommand> Commands();
public IList<IUICommand> Commands { get; }
var iVector = popupMenu.commands;
Public ReadOnly Property Commands As IList(Of IUICommand)

Property Value


The commands for the context menu.


Add your commands to the context menu after you create a new PopupMenu. Create a UICommand object for each command and append the commands to the context menu.

The Context menu sample creates and appends a new UICommand that specifies a handler function, which runs if the command is invoked.

menu.commands.append(new Windows.UI.Popups.UICommand("Open with", onOpenWith));

The Context menu sample also creates and appends a new UICommand that specifies a command identifier, which can be used to determine the command that has been invoked.

menu.commands.append(new Windows.UI.Popups.UICommand("Copy", null, 1));

The Context menu sample places a separator between its "Copy" and "Highlight" commands like this.

menu.commands.append(new Windows.UI.Popups.UICommand("Copy", null, 1));
menu.commands.append(new Windows.UI.Popups.UICommandSeparator);
menu.commands.append(new Windows.UI.Popups.UICommand("Highlight", null, 2));
menu.commands.append(new Windows.UI.Popups.UICommand("Look up", null, 3));


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.

Applies to

See also