使用Tiles模板windows8

时间:2012-10-15 14:24:46

标签: xaml windows-8 microsoft-metro tiles

我正在尝试使用切片模板(显示图像的切片并切换到显示文本)

http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx#TileSquarePeekImageAndText04

问题是:我把这个XML放在哪里,如何在XAML中调用它?

祝你好运

1 个答案:

答案 0 :(得分:1)

您没有在XAML中调用它,而是将其提供给TileUpdater实例,您可以在下面的TileUpdateManager文档中看到。这种简单的方案处理local notification(但您可以利用scheduledperiodicpush通知。

查看App tiles and badgesPush and periodic notifications样本以获取指导。

function sendTileTextNotification() {
    var Notifications = Windows.UI.Notifications;

    // Get an XML DOM version of a specific template by using getTemplateContent.
    var tileXml = Notifications.TileUpdateManager.getTemplateContent(Notifications.TileTemplateType.tileWideText03);

    // You will need to look at the template documentation to know how many text fields a particular template has.
    // Get the text attribute for this template and fill it in.
    var tileAttributes = tileXml.getElementsByTagName("text");
    tileAttributes[0].appendChild(tileXml.createTextNode("Hello World!"));

    // Create the notification from the XML.
    var tileNotification = new Notifications.TileNotification(tileXml);

    // Send the notification to the calling app's tile.
    Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
}