Home > Metro, Windows 8 > Windows 8 Tile Badges

Windows 8 Tile Badges

This is a follow up post to my last one, which was Windows 8 Tile Notifications.

Badges are another nice way, to display application data on the start tile.

There are two different sets of badges:

– Numbers, which can be in the range from 0..99
            (with larger values the display will remain at 99, 0 will clear the display at all)

– Glyphs, which can be one of 12 predefined icons, see here

Both sets appear in the lower right corner of a tile, either on top of the standard tile or any other custom tile data.

Badges can be used pretty much the same way as Tiles. The following code fragments are need for enabling Badges:

  1. Fetch one of the predefined templates as XML: (Number or Glyph)
    XmlDocument xmlDoc = 
    BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

    XmlDocument xmlDoc = 
    BadgeUpdateManager.GetTemplateContent(badgeTemplateType); // using BadgeTemplateType.BadgeNumber or .BadgeGlyph will return: // <badge value=""/>

  2. Update the badge value

  3. var node = xmlDoc.SelectSingleNode("/badge");
    node.Attributes[0].NodeValue = badgeValue;
    

    .

  4. Get a BadgeUpdater and perform the update

    BadgeNotification badgeNotification = new BadgeNotification(xmlDoc);
    BadgeUpdateManager.CreateBadgeUpdaterForApplication()
    .Update(badgeNotification);

  5.  

      Clearing badge values and expiration is done the same way as tiles

        BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
        BadgeNotification badgeNotification = new BadgeNotification(xmlDoc);
        badgeNotification.ExpirationTime 
        =
        new DateTimeOffset(DateTime.Now.AddSeconds(10));

        Categories: Metro, Windows 8
        1. No comments yet.
        1. No trackbacks yet.

        Leave a Reply

        Fill in your details below or click an icon to log in:

        WordPress.com Logo

        You are commenting using your WordPress.com account. Log Out /  Change )

        Google photo

        You are commenting using your Google account. Log Out /  Change )

        Twitter picture

        You are commenting using your Twitter account. Log Out /  Change )

        Facebook photo

        You are commenting using your Facebook account. Log Out /  Change )

        Connecting to %s

        %d bloggers like this: