【问题标题】:Creating Message Box Button in Windows Phone 8.1在 Windows Phone 8.1 中创建消息框按钮
【发布时间】:2015-10-29 13:08:29
【问题描述】:

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

我google了一下,了解到只有使用第三方API才能为消息框创建自己的按钮。

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

【问题讨论】:

    标签: windows windows-phone-8.1


    【解决方案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

    【讨论】:

    • MessageDialog 在 Windows Phone 8.1 (WinRT) 中使用,我认为这个问题是针对MessageBox 在 Windows Phone 8.1 (Silverlight) 中使用的
    • 也许你是对的。我们需要作者澄清这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多