在Live Tile上显示生成的图像

时间:2012-11-09 04:20:46

标签: windows-8 microsoft-metro live-tile

我在我的应用中创建了一个自定义图像(例如通过捕获墨迹数据),然后想要在Live Tile上显示生成的图像。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

您需要做的就是将图像分配到实时图块模板。

TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);

XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = "Hello World! My very own tile notification";

XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///images/redWide.png");
((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");

XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode("Hello World! My very own tile notification"));
IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

TileNotification tileNotification = new TileNotification(tileXml);

tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);

TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

答案 1 :(得分:0)

Jeff Blankenburg的以下博客文章可以作为您想要了解的有关Live Tiles的所有内容的起点:

31 Days of Windows 8