小编Car*_*son的帖子

MessageDialog在具有3个命令的Windows Phone 8.1上中断

我正在尝试使用3个命令将MessageDialog添加到Windows Phone 8.1应用程序(WinRT).查看MessageDialog的文档:

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.popups.messagedialog.aspx

它说"对话框有一个命令栏,可以支持最多三个命令",所以我认为这不会是一个问题.我拿了他们的例子(在文档中找到)并制作了一个简单的测试应用程序,它在桌面和Windows手机上都运行得很好.然后,我采用相同的示例并向其添加了一个命令:

var messageDialog = new MessageDialog("No internet connection has been found.");

// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
messageDialog.Commands.Add(new UICommand(
    "Try again",
    new UICommandInvokedHandler(this.CommandInvokedHandler)));
messageDialog.Commands.Add(new UICommand(
    "Something else",
    new UICommandInvokedHandler(this.CommandInvokedHandler)));
messageDialog.Commands.Add(new UICommand(
    "Close",
    new UICommandInvokedHandler(this.CommandInvokedHandler)));

// Set the command that will be invoked by default
messageDialog.DefaultCommandIndex = 0;

// Set the command to be invoked when escape is pressed
messageDialog.CancelCommandIndex = 1;

// Show …
Run Code Online (Sandbox Code Playgroud)

c# messagedialog windows-runtime windows-phone-8.1

12
推荐指数
1
解决办法
1万
查看次数