如何同时更新每个代码的方形和宽平铺?或者,我如何确定启动屏幕上哪个瓦片类型"已加载"?
我有这个代码:
private void JamesBond()
{
var tileXML = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
var tileText = tileXML.GetElementsByTagName("text");
(tileText[0] as XmlElement).InnerText = "First text";
(tileText[1] as XmlElement).InnerText = "Second text";
(tileText[2] as XmlElement).InnerText = "Third text";
(tileText[3] as XmlElement).InnerText = "Last text";
var tileNotification = new TileNotification(tileXML);
var tileXMLw = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text01);
var tileTextw = tileXMLw.GetElementsByTagName("text");
(tileTextw[0] as XmlElement).InnerText = "Wide First text";
(tileTextw[1] as XmlElement).InnerText = "Wide Second text";
(tileTextw[2] as XmlElement).InnerText = "Wide Third text";
(tileTextw[3] as XmlElement).InnerText = "Wide Last text";
var tileNotificationW = new TileNotification(tileXMLw);
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotificationW);
}
}
它所做的是,它更新宽磁贴。但如果它是方形瓷砖,那么它会更新它……有时。大多数时候,它是空的。所以,不知怎么的,它起作用了。但不对。。。。
有人能帮我吗?
附言:我还试图获得TileUpdater实例,并在同一个实例中完成所有操作。。更糟糕的是,它只显示宽瓷砖。。。
提前谢谢。
谨致问候,ben0bi
解决了这个问题。根据MSDN,我们必须合并这两个xml,以便它们出现在同一个"可视化"标记下。
我是这样做的:
string xml="<tile>n";
xml += "<visual version="2">n";
xml += " <binding template="TileSquare150x150Text01" fallback="TileSquareText01">n";
xml += " <text id="1">Row 0</text>n";
xml += " <text id="2">Row 1</text>n";
xml += " <text id="3">Row 2</text>n";
xml += " <text id="4">Row 3</text>n";
xml += " </binding>n";
xml += " <binding template="TileWide310x150Text01" fallback="TileWideText01">n";
xml += " <text id="1">Wide Row 0</text>n";
xml += " <text id="2">Wide Row 1</text>n";
xml += " <text id="3">Wide Row 2</text>n";
xml += " <text id="4">Wide Row 3</text>n";
xml += " </binding>n";
xml+="</visual>n";
xml +="</tile>";
XmlDocument txml = new XmlDocument();
txml.LoadXml(xml);
TileNotification tNotification = new TileNotification(txml);
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
TileUpdateManager.CreateTileUpdaterForApplication().Update(tNotification);