示例代码:
XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
// We are setting attribute value 6
badgeElement.SetAttribute("value", "6");
// Create a badge notification from XML
BadgeNotification badgeNotification = new BadgeNotification(badgeXml);
// Send the notification to the secondary tile
BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId);
badgeUpdater.Update(badgeNotification);
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText04);
// Refer to template documentation to determine how many text fields a particular template has
// get the text attributes for this template and fill them in
XmlNodeList tileTextElements = tileXml.GetElementsByTagName("text");
tileTextElements.Item(0).AppendChild(tileXml.CreateTextNode("Sent to a secondary tile!"));
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
XmlNodeList squareTileTextElements = squareTileXml.GetElementsByTagName("text");
squareTileTextElements.Item(0).AppendChild(squareTileXml.CreateTextNode("Sent to a secondary tile!"));
// Include the square template in the notification
IXmlNode subNode = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
tileXml.GetElementsByTagName("visual").Item(0).AppendChild(subNode);
// Create the notification from the XML
TileNotification tileNotification = new TileNotification(tileXml);
// Send the notification to the secondary tile by creating a secondary tile updater
TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId);
tileUpdater.Update(tileNotification); Toast