Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MessageDialog.CancelCommandIndex | cancelCommandIndex property

Applies to Windows and Windows Phone

Gets or sets the index of the command you want to use as the cancel command. This is the command that fires when users press the ESC key.

Add the commands before you set the index.

Syntax


var cancelCommandIndex = messageDialog.cancelCommandIndex;
messageDialog.cancelCommandIndex = cancelCommandIndex;

Property value

Type: Number [JavaScript] | System.UInt32 [.NET] | uint32 [C++]

The index of the cancel command.

Remarks

Use message dialogs to send critical or blocking messages and questions from the app.

ValueWhen to use
≥0

The dialog offers a safe default choice that is the equivalent of cancellation, like "Cancel" or "Close." Set CancelCommandIndex to the index of the command handler for that cancel/close command, so that when the user dismisses the dialog through a noncommital action, like pressing ESC, the API returns the command handler you want.

Note  Generally, you should avoid creating dialogs that can be dismissed this way and that re-launch asking the same question or sending the same message again and again. They make the app noisy and tend to annoy users.

-1

The user is required to make an explicit decision like tapping a specific button on the dialog. This ensures that the user can't dismiss the dialog through a noncommital action like pressing ESC.

-2Not recommended.

The dialog is not dismissed when the user presses ESC or during an incoming contract activation; however, if the app re-uses the main app window when responding to incoming activations, the dialog's command handlers will no longer be valid. Because the API doesn't handle this behavior, we recommend not using this value.

 

Error handling on dismissal by a contract activation

If the app receives an incoming contract activation (like from Search, Share, Settings, Devices or the file picker contracts) while the dialog is showing, the dialog is programmatically dismissed, regardless of the property value that has been set for the CancelCommandIndex.

To help you handle this case, the API returns a dummy command handler. You, then, can decide how to handle and react to the error.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

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

Metadata

Windows.winmd

See also

MessageDialog

 

 

Show:
© 2014 Microsoft