【问题标题】:How to prevent the ContentDialog from closing when home key is pressed in Windows phone 8.1..?如何防止在 Windows phone 8.1 中按下 Home 键时关闭 ContentDialog ..?
【发布时间】:2015-03-03 00:50:47
【问题描述】:
private IAsyncOperation<ContentDialogResult> _Task = null;
private ContentDialog _message = null;            


        _message = new ContentDialog()
        {
            Content = "Hello",
            PrimaryButtonText = "EXIT",
            IsPrimaryButtonEnabled = true,
        };

        _message.PrimaryButtonClick += message_PrimaryButtonClick;
        _Task = _message.ShowAsync();

这里我为内容对话框创建了一个任务,这样我就可以从代码中显式关闭 ContenDialog。

 How can I prevent dialog from closing when Home key is pressed and relaunched 

【问题讨论】:

    标签: windows-phone-8.1 messagedialog


    【解决方案1】:

    为防止对话框关闭,请处理其Closing 事件并在其ContentDialogClosingEventArgs 参数中将Cancel 设置为true。

    初始化对话框时:

    myContentDialog.Closing += ContentDialog_Closing; 
    

    事件处理程序:

    void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
    {
        if (doNotClose)
        {
            args.Cancel = true;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多