我正在尝试在磁贴上安排几条消息进行更新,但第二种方法的第 4 行 tileTextAttributes[0].InnerText = Message;
不断抛出异常,说明参数不正确。你能帮我解决问题吗?
private void SetupTiles()
{
try
{
DateTimeOffset time = DateTime.Now;
for (int i = 0; i < messages.Count; i++)
{
Windows.UI.Notifications.ScheduledTileNotification stf = new ScheduledTileNotification(GetTile(messages[i]), time);
time.Add(new TimeSpan(0, 0, 0, 30, 0));
TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stf);
}
}
catch (Exception ex)
{
new Windows.UI.Popups.MessageDialog(ex.Message).ShowAsync();
}
}
XmlDocument GetTile(string Message)
{
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText05);
string t = tileXml.ToString();
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = Message;
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(Message));
IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
return tileXml;
}
编辑
System.ArgumentException:参数不正确。
在
Windows.UI.Notifications.ScheduledTileNotification..ctor(XmlDocument content, DateTimeOffset deliveryTime)
在
c:\Users\ddds\Documents\Visual Studio 2012\Projects\TestProj\TestProj\MainPage.xaml 中的 TestProj.MainPage.SetupTiles()。 CS:第 398 行