【问题标题】:Windows.UI.Popups.MessageDialog() is not working in Metro App?Windows.UI.Popups.MessageDialog() 在 Metro App 中不起作用?
【发布时间】:2012-06-21 03:08:58
【问题描述】:

我正在尝试在我的 Metro 应用程序中打印警报,但它不起作用?这里我使用 Visual Studio2012(HTML,WinJS)和 windows8RC 来开发应用程序。有人可以建议我吗?

提前致谢。

【问题讨论】:

    标签: html microsoft-metro visual-studio-2012 winjs


    【解决方案1】:

    除非是严重错误,否则我建议使用 FlyOut:

    HTML:

    <!-- Define a flyout in HTML as you wish -->
    <div id="informationFlyout" data-win-control="WinJS.UI.Flyout">
        <p>
            Some informative text
        </p>
    </div>
    
    <!-- an anchor for the flyout, where it should be displayed -->
    <div id="flyoutAnchor"></div>
    

    JS:

        // Get an anchor for the flyout
        var flyoutAnchor = document.getElementById("flyoutAnchor"); 
    
        // Show flyout at anchor
        document.getElementById("informationFlyout").winControl.show(flyoutAnchor); 
    

    要在设定的时间后关闭弹出窗口,您可以执行 setTimeout 并隐藏在您的代码中:

    // execute this code after 2000ms
    setTimeout(function () {
    
        // Fetch the flyout
        var flyout = document.getElementById("informationFlyout"); // Get the flyout from HTML
    
        // Check if the element still exists in DOM
        if (flyout) 
            flyout.winControl.hide(); // Dismiss the flyout
    
    }, 2000); 
    

    阅读有关 FlyOut 弹出窗口的更多信息here

    【讨论】:

      【解决方案2】:

      你能提供你的代码吗? 这对我有用:

      Windows.UI.Popups.MessageDialog("Content", "Title").showAsync();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多