Skip to main content
BadgeUpdateManager.GetTemplateContent | getTemplateContent method

Applies to Windows and Windows Phone

Gets the XML content of one of the predefined badge templates so that you can customize it for a badge update.

Syntax


var xmlDocument = Windows.UI.Notifications.BadgeUpdateManager.getTemplateContent(type);

public static XmlDocument GetTemplateContent(
  BadgeTemplateType type
)

Public Shared Function GetTemplateContent(
  type As BadgeTemplateType 
) As XmlDocument

public:
static XmlDocument^ GetTemplateContent(
  BadgeTemplateType type
)

Parameters

type

Type: BadgeTemplateType

The type of badge template, either a glyph or a number.

Return value

Type: XmlDocument

The object that contains the template XML.

Remarks

Instead of creating the full XML payload yourself, you can get the default template and then use Document Object Model (DOM) manipulation functions to customize the part of the content that you want to change. You package this XML in a BadgeNotification and send it to the tile through the BadgeUpdater that you create through the other methods of this class.

See badge schema for an explanation of badge elements and attributes.

Examples

The following example shows the use of GetTemplateContent to get the content for a numeric badge.


var Notifications = Windows.UI.Notifications;

var badgeXml = Notifications.BadgeUpdateManager.getTemplateContent(Notifications.BadgeTemplateType.badgeNumber);
var badgeAttributes = badgeXml.getElementsByTagName("badge");
badgeAttributes[0].setAttribute("value", "7");

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.UI.Notifications
Windows::UI::Notifications [C++]

Metadata

Windows.winmd

See also

BadgeUpdateManager
App tiles and badges sample
Guidelines and checklist for tiles and badges
How to clear a badge
How to send a glyph or numeric badge in a local notification
How to set up periodic notifications for badges
How to update a badge through push notifications
Badge XML schema
Badge overview