UICommand.UICommand constructors

Expand
This topic has not yet been rated - Rate this topic

UICommand.UICommand constructors

[This documentation is preliminary and is subject to change.]

Creates a new instance of the UICommand class.
This member is overloaded. For complete information about this member, including syntax and usage, click a name in the overload list.

Overload list

ConstructorDescription
UICommand() Creates a new instance of the UICommand class.
UICommand(String) Creates a new instance of the UICommand class using the specified label.
UICommand(String, UICommandInvokedHandler) Creates a new instance of the UICommand class using the specified label and event handler.
UICommand(String, UICommandInvokedHandler, Object) Creates a new instance of the UICommand class using the specified label, event handler, and command identifier.

Remarks

You can see complete code examples that demonstrate how to create and customize context menus in the Context menu sample on the Metro style app sample home page.

Examples

Create a UICommand object for each command and append the commands to the context menu using the PopupMenu.Commands property.

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", function (command) {
    // Add command handler code here
    sdkSample.displayStatus("'" + command.label + "' selected");
}));


The signature of a handler function for a command (like the onOpenWith function in the example) is described by UICommandInvokedHandler.

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


Requirements

Minimum supported client

Windows 8 Release Preview

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Popups
Windows::UI::Popups [C++]

Metadata

Windows.winmd

See also

Adding context menus
Context menu sample
Guidelines and checklist for context menus
Reference
IUICommand
Object
PopupMenu.Commands
UICommand

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD