在 Windows phone 8.1 中按下 Home 键时,如何防止 ContentDialog 关闭? [英] How to prevent the ContentDialog from closing when home key is pressed in Windows phone 8.1..?

查看:21
本文介绍了在 Windows phone 8.1 中按下 Home 键时,如何防止 ContentDialog 关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

Here I have created a Task for content Dialog, so that I can close the ContenDialog explicitly from code.

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

推荐答案

防止对话框关闭处理其 Closing 事件并设置 取消在其ContentDialogClosingEventArgs 参数.

To prevent the dialog from closing handle its Closing event and set Cancel to true in its ContentDialogClosingEventArgs argument.

初始化对话框时:

myContentDialog.Closing += ContentDialog_Closing; 

事件处理程序:

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

这篇关于在 Windows phone 8.1 中按下 Home 键时,如何防止 ContentDialog 关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆