在Windows Phone 8.1中创建消息框按钮

时间:2015-10-27 03:57:18

标签: windows windows-phone-8.1

如何在Windows Phone 8.1中创建自定义消息框按钮?

我用谷歌搜索并了解只有使用第三方API才能为消息框创建一个自己的按钮。

是否有任何内置方法可以更改消息框中的确定和取消按钮?

1 个答案:

答案 0 :(得分:1)

您可以通过添加命令来自定义按钮的标签,例如: `//创建消息对话框并设置其内容     var messageDialog = new MessageDialog(“找不到互联网连接。”);

// 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(
    "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 the message dialog
await messageDialog.ShowAsync();

此处提供更多信息https://msdn.microsoft.com/pl-pl/library/windows/apps/br208674?cs-save-lang=1&cs-lang=csharp#code-snippet-2