简体   繁体   中英

Updating secondary tiles with images in Windows 10 app

I was able to pin a secondary tile in my windows 10 app. I was trying to update the secondary tile via a background task. I am trying to use the template TileWide310x150PeekImageCollection01 which should show up five images (one large to the left and 4 small to the right) on 310x150 tile. But it doesn't work like it suppose to be. I am trying to setup the images like this:

TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(mysecondarytileID);
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection01);
XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx://Assets/wide310x150-sdk.png");
((XmlElement)tileImageAttributes[1]).SetAttribute("src", "ms-appx://Assets/wide310x150-sdk.png");
((XmlElement)tileImageAttributes[2]).SetAttribute("src", "ms-appx://Assets/wide310x150-sdk.png");
((XmlElement)tileImageAttributes[3]).SetAttribute("src", "ms-appx://Assets/wide310x150-sdk.png");
((XmlElement)tileImageAttributes[4]).SetAttribute("src", "ms-appx://Assets/wide310x150-sdk.png");
TileNotification tileNotification = new TileNotification(tileXml);
tileUpdater.Update(tileNotification);

I suspect maybe the location for image is wrong.I tried putting in urls but that doesn't work either. I was able to send a text notification if I used another template though. I don't know why I cannot send any images to the secondary tile. Am I missing something which needs to be set before sending a tile update. Please help.

First of all, the Tile Template Catalog is depreciated (most of the templates continue to work for legacy purposes). We now recommend using Adaptive Tile Templates , which allow you to create your own tiles instead of being restricted to a set of templates.

Secondly, all of the legacy image collection templates will NOT work in Windows 10 . So do not use TileWide310x150PeekImageCollection01 in your app, for example. Instead, create something with the adaptive templates.

And finally, your image URL's are invalid. ms-appx and ms-appdata need three slashes after them, like ms-appx:///Assets/img.jpg . However, here's an optimization - for ms-appx, you can drop the leading content and simply have Assets/img.jpg .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM