0

I hoped this code from page 549 of Nathan's "Windows 8 Apps with XAML and C#":

    //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.

How can I accomplish the same thing in WP8 from my ScheduledTaskAgent?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

2 Answers2

3

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.

The WP8 Tile sample on MSDN shows more detailed code.

Nathan Kuchta
  • 13,482
  • 2
  • 26
  • 35
1
XmlDocument badgeDOM = new XmlDocument();
badgeDOM.LoadXml(string.Format("<badge value='{0}'/>", 42));
BadgeNotification badge = new BadgeNotification(badgeDOM);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
NeoSvet
  • 151
  • 1
  • 4