Search code examples
c#xmlwindows-phone-8windows-store-appsbadge

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#":

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


Solution

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