在Windows Phone 8.1中更新动态磁贴

3

我正试图为Windows Phone 8.1构建一个自定义日历应用程序,并希望在应用程序磁贴上显示当前日期和时间。我正在尝试使用以下代码更新我的Windows Phone 8.1应用程序在开始屏幕上的磁贴:

 XmlDocument tileXml2 = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageAndText01);
        var textElement2 = tileXml2.GetElementsByTagName("text")[0].AppendChild(tileXml2.CreateTextNode("some text"));

        var tileImage = tileXml2.GetElementsByTagName("image")[0] as XmlElement;
        tileImage.SetAttribute("src", "ms-appx:///Assets/WideLogo.png");


        var tn2 = new TileNotification(tileXml2);
        TileUpdateManager.CreateTileUpdaterForApplication().Update(tn2);


        XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Block);
        var textElement = tileXml.GetElementsByTagName("text")[0].AppendChild(tileXml.CreateTextNode("01"));
        textElement = tileXml.GetElementsByTagName("text")[1].AppendChild(tileXml.CreateTextNode("Tue"));
        var tn = new TileNotification(tileXml);
        //.CreateTileUpdaterForApplication().
        //TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdate()
        TileUpdateManager.CreateTileUpdaterForApplication("App").Clear();
        TileUpdateManager.CreateTileUpdaterForApplication("App").Update(tn);

但是,当我运行代码时,只有TileSquare150x150Block被更新了,而在更改磁贴大小时,TileWide310x150PeekImageAndText01没有被更新。
请问您能否帮我更新多个磁贴?另外,我该如何在应用磁贴上获取当前日期?谢谢!
1个回答

1
由于您在注册TileWide310x150PeekImageAndText01之后调用了TileUpdateManager.CreateTileUpdaterForApplication("App").Clear(),因此所有更新都被删除。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接