0

タイトルの通り、

HTML5 Windows ストア アプリのコードから MessageDialog を閉じるにはどうすればよいですか?

これまでの私のコード:

var msg = new Windows.UI.Popups.MessageDialog("Please wait");
msg.commands.append(new Windows.UI.Popups.UICommand("OK",
    function (command) {
        ...
    }));
msg.showAsync();

そして、コードからこのポップアップを閉じたいのですが、仕様に次のようなメソッドが見つかりませんでした

msg.close();

方法はありますか?

ありがとう

4

3 に答える 3

1

この答えと同じように、フライアウトを使用したいと思います。リンクは、タイムアウト後にフライアウトを閉じるという点で、わずかに異なる問題を解決します。

ただし、ユーザーだけでなく自分も閉じることができるフライアウトを定義できる必要があります。どちらの場合も、次のように呼び出すことになります。

flyout.winControl.hide(); // Dismiss the flyout
于 2013-03-10T14:47:31.197 に答える
1

あなたのメッセージが「お待ちください」であるという事実は、この仕事には別のツールを使用することをお勧めします。

バックグラウンドで待機する必要があることをユーザーに通知する場合は、次のドキュメントに記載されているように、代わりにプログレス コントロールを使用することを検討してください。

http://msdn.microsoft.com/en-us/library/windows/apps/hh465487.aspx

プログレス コントロールを使用する場合は、目的のテキストを含むテキスト ラベルを含めることも、ユーザーに待機させるタスクが完了したらプログレス コントロールを閉じることもできます。

元の質問に答えるために、プログラムで MessageDialog を閉じるための API はないと思います。これは、アプリがメッセージを表示し、ユーザーがそれを閉じることができるようにするこのコントロールの対話パターンを壊すためです。彼らがする準備ができたら。

それが役立つことを願っています。

Windows ストア アプリ開発の詳細については、App Builderに登録してください。

于 2013-03-09T21:12:38.157 に答える
0

これを見てください...

(function(){
"use strict"; 
    var page = WinJS.UI.Pages.define("/html/cancelcommand.html", { 
        ready: function (element, options) { 
            document.getElementById("cancelCommand").addEventListener("click", cancelCommand_Click, false); 
        } 
    }); 

    // Click handler for the 'cancelCommand' button. 
    // Demonstrates setting the command to be invoked when the 'escape' key is pressed. 
    // Also demonstrates retrieval of the label of the chosen command and setting a callback to a function. 
    // A message will be displayed indicating which command was invoked. 
    // In this scenario, 'Try again' is selected as the default choice, and the 'escape' key will invoke the command named 'Close' 
    function cancelCommand_Click() { 
        // Create the message dialog and set its content 
        var msg = new Windows.UI.Popups.MessageDialog("No internet connection has been found."); 

        // Add commands and set their command handlers 
        msg.commands.append(new Windows.UI.Popups.UICommand("Try again", commandInvokedHandler)); 
        msg.commands.append(new Windows.UI.Popups.UICommand("Close", commandInvokedHandler)); 

        // Set the command that will be invoked by default 
        msg.defaultCommandIndex = 0; 

        // Set the command to be invoked when escape is pressed 
        msg.cancelCommandIndex = 1; 

        // Show the message dialog 
        msg.showAsync(); 
    } 

    function commandInvokedHandler(command) { 
        // Display message 
        WinJS.log && WinJS.log("The '" + command.label + "' command has been selected.", "sample", "status"); 
    } 
}());

http://code.msdn.microsoft.com/windowsapps/Message-dialog-sample-00c928f5/sourcecode?fileId=50972&pathId=1064922824

于 2013-03-09T17:59:00.433 に答える