【发布时间】:2015-10-29 13:08:29
【问题描述】:
如何在 Windows Phone 8.1 中创建自定义消息框按钮?
我google了一下,了解到只有使用第三方API才能为消息框创建自己的按钮。
是否有任何内置方法可以更改消息框中的确定和取消按钮?
【问题讨论】:
如何在 Windows Phone 8.1 中创建自定义消息框按钮?
我google了一下,了解到只有使用第三方API才能为消息框创建自己的按钮。
是否有任何内置方法可以更改消息框中的确定和取消按钮?
【问题讨论】:
您可以通过添加命令来自定义按钮的标签,例如: ` // 创建消息对话框并设置其内容 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();
【讨论】:
MessageDialog 在 Windows Phone 8.1 (WinRT) 中使用,我认为这个问题是针对MessageBox 在 Windows Phone 8.1 (Silverlight) 中使用的