简体   繁体   English

如何在WP8中更新应用程序的Live Tile Badge?

[英]How can I update my app's Live Tile Badge in WP8?

I hoped this code from page 549 of Nathan's "Windows 8 Apps with XAML and C#": 我希望Nathan的“带有XAML和C#的Windows 8应用程序”的第549页的代码:

    //string xmlString = @"<badge value='2'/>";
    string xmlString = string.Format(@"<badge value={0}/>", 42);
    XmlDocument document = new XmlDocument(); 
    document.LoadXml(xmlString); 
    BadgeNotification notification = new BadgeNotification(document);
    BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notification);

...would also work for WP8, but many of the classes are unrecognized in my WP8 ScheduledTaskAgent, namely XmlDocument, BadgeNotification, and BadgeUpdateManager. ...同样适用于WP8,但是我的WP8 ScheduledTaskAgent中无法识别许多类,即XmlDocument,BadgeNotification和BadgeUpdateManager。

How can I accomplish the same thing in WP8 from my ScheduledTaskAgent? 如何从ScheduledTaskAgent在WP8中完成相同的任务?

The APIs for updating a badge on WP8 are different than those on Windows 8. The badge value can be set using the Count property on a StandardTileData object. WP8上用于更新标志的API与Windows 8上的API不同。可以使用StandardTileData对象上的Count属性来设置标志值。

The WP8 Tile sample on MSDN shows more detailed code. MSDN上的WP8 Tile示例显示了更详细的代码。

XmlDocument badgeDOM = new XmlDocument();
badgeDOM.LoadXml(string.Format("<badge value='{0}'/>", 42));
BadgeNotification badge = new BadgeNotification(badgeDOM);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM