7
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 
4

1 に答える 1

11

ダイアログが閉じないようにするには、そのClosingイベントを処理し、そのContentDialogClosingEventArgs引数でCancelを true に設定します。

ダイアログを初期化するとき:

myContentDialog.Closing += ContentDialog_Closing; 

イベント ハンドラ:

void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
    if (doNotClose)
    {
        args.Cancel = true;
    }
}
于 2015-03-02T16:50:47.753 に答える