在Windows 10应用程序中使用图像更新辅助磁贴

时间:2015-08-28 18:48:57

标签: c# windows-runtime win-universal-app windows-10

我能够在我的Windows 10应用中固定辅助磁贴。我试图通过后台任务更新辅助磁贴。我正在尝试使用模板TileWide310x150PeekImageCollection01,它应该在310x150磁贴上显示五个图像(一个大到左边,四个小到右边)。但它并没有像它想象的那样工作。我试图像这样设置图像:

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);

我怀疑图像的位置可能是错误的。我尝试放入网址,但这也不起作用。如果我使用了另一个模板,我能够发送文本通知。我不知道为什么我不能将任何图像发送到辅助磁贴。在发送磁贴更新之前,我是否遗漏了需要设置的内容。请帮忙。

1 个答案:

答案 0 :(得分:4)

首先,折旧平铺模板目录(大多数模板继续用于传统目的)。 我们现在建议您使用Adaptive Tile Templates ,这样您就可以创建自己的图块,而不是仅限于一组模板。

其次,所有旧版图像集合模板在Windows 10中都不起作用。因此,请勿在您的应用中使用TileWide310x150PeekImageCollection01。相反,使用自适应模板创建一些东西。

最后,您的图片网址无效。 ms-appx和ms-appdata需要三个斜杠,比如ms-appx:///Assets/img.jpg。但是,这是一个优化 - 对于ms-appx,您可以删除主要内容,只需Assets/img.jpg