PopupMenu.Commands PopupMenu.Commands PopupMenu.Commands PopupMenu.Commands PopupMenu.Commands Property


Gets the commands for the context menu.

public : IVector<IUICommand> Commands { get; }
IVector<IUICommand> Commands();
public IList<IUICommand> Commands { get; }
Public ReadOnly Property Commands As IList<IUICommand>
var iList = popupMenu.commands;

Property Value

IList<IUICommand> IList<IUICommand> IList<IUICommand>

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.

See also