Udostępnij za pośrednictwem


PopupMenu.Commands Property

Definition

Gets the commands for the context menu.

public:
 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.

Examples

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));

Remarks

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

Applies to

See also