来自本地主机的Windows 8磁贴通知

来自本地主机的Windows 8磁贴通知,windows,windows-8,microsoft-metro,tile,Windows,Windows 8,Microsoft Metro,Tile,我正在为Windows8开发一个简单的应用程序。在我的应用程序中,我希望“开始”磁贴显示我随应用程序附带的本地主机的图像。 例如,我像wise一样将图像保持在/images/tile1.jpg上。 我的xml代码是 <tile> <visual> <binding template="TileWideImage"> <image id="1" src ="http://localhost/images/tile1.jpg" /&g

我正在为Windows8开发一个简单的应用程序。在我的应用程序中,我希望“开始”磁贴显示我随应用程序附带的本地主机的图像。 例如,我像wise一样将图像保持在/images/tile1.jpg上。 我的xml代码是

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

我只是不知道代码出了什么问题。请帮忙。

好吧,你不能。不允许环回,因此如果您使用的是本地主机服务,您的应用程序将无法通过认证

你能用应用程序本身传送图像吗?或者,设置一个外部服务来托管图像和磁贴。你真的只需要像WindowsAzure blob存储这样的东西,甚至不需要托管web服务

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

    // 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();
})();