0

我正在为 Windows 8 开发一个简单的应用程序。在我的应用程序中,我希望开始磁贴显示来自我的应用程序附带的本地主机的图像。例如,我将图像保存在 /images/tile1.jpg 上。我的xml代码是

<tile>
<visual>
    <binding template="TileWideImage">
        <image id="1" src ="http://localhost/images/tile1.jpg" />
    </binding>
</visual>

同样存在于 /tile1.xml

我的 default.js 代码是

    // For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
    "use strict";

    WinJS.Binding.optimizeBindingReferences = true;

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                var notifications = Windows.UI.Notifications;
                var recurrence = notifications.PeriodicUpdateRecurrence.halfHour;


                var urls = [
                    new Windows.Foundation.Uri("http://localhost/tile1.xml"),
                    new Windows.Foundation.Uri("http://localhost/tile2.xml"),
                    new Windows.Foundation.Uri("http://localhost/tile3.xml"),
                    new Windows.Foundation.Uri("http://localhost/tile4.xml")
                ];


                notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);
                notifications.TileUpdateManager.createTileUpdaterForApplication().startPeriodicUpdateBatch(urls, recurrence);

            } else {
                // TODO: This application has been reactivated from suspension.
                // Restore application state here.
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

    app.oncheckpoint = function (args) {
        // TODO: This application is about to be suspended. Save any state
        // that needs to persist across suspensions here. You might use the
        // WinJS.Application.sessionState object, which is automatically
        // saved and restored across suspension. If you need to complete an
        // asynchronous operation before your application is suspended, call
        // args.setPromise().
    };


  app.start();
})();

我只是无法弄清楚代码有什么问题。请帮忙。

4

1 回答 1

0

好吧,你不能。不允许环回,因此如果您使用 localhost 服务,您的应用将无法通过认证。

您可以使用应用程序本身提供图像吗?或者,设置外部服务来托管您的图像和图块。您真的只需要像 Windows Azure blob 存储这样的东西,甚至不需要托管 Web 服务。

最后,您需要确保始终包含方形平铺图像。用户始终拥有控制权,因此他们可能会选择不将您的应用显示为宽磁贴。

于 2012-12-08T16:47:48.353 回答