BadgeNotification BadgeNotification BadgeNotification BadgeNotification Class

Definition

Defines the content, associated metadata, and expiration time of an update to a tile's badge overlay. A badge can display a number from 1 to 99 or a status glyph.

public sealed class BadgeNotificationpublic sealed class BadgeNotificationPublic NotInheritable Class BadgeNotificationpublic sealed class BadgeNotification
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Examples

The following example code uses the @Windows.UI.Notifications.BadgeNotification.#ctor(Windows.Data.Xml.Dom.XmlDocument) method to create a numeric badge notification. If you used this method to set the value to "0", it would clear the badge.


var Notifications = Windows.UI.Notifications;

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

// Create a badge notification from XML
var badgeNotification = new Notifications.badgeNotification(badgeXml);

The following example code uses the @Windows.UI.Notifications.BadgeNotification.#ctor(Windows.Data.Xml.Dom.XmlDocument) method to create a glyph badge notification. If you used this method to set the value to "none", it would clear the badge.


var Notifications = Windows.UI.Notifications;

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

// Create a badge notification from XML
var badgeNotification = new Notifications.badgeNotification(badgeXml);

Constructors

BadgeNotification(XmlDocument) BadgeNotification(XmlDocument) BadgeNotification(XmlDocument) BadgeNotification(XmlDocument)

Creates and initializes a new instance of the BadgeNotification.

public BadgeNotification(XmlDocument content)public New(XmlDocument content)Public Sub New(content As XmlDocument)public BadgeNotification(XmlDocument content)
Parameters
content
XmlDocument XmlDocument XmlDocument XmlDocument

The XML content that defines the badge update.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The value attribute can be a number from 1-99 or a status glyph. See the Badge overview for a complete list of available images.

Examples

The following example code uses the @Windows.UI.Notifications.BadgeNotification.#ctor(Windows.Data.Xml.Dom.XmlDocument) method to create a numeric badge notification.



var Notifications = Windows.UI.Notifications;


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


// Create a badge notification from XML
var badgeNotification = new Notifications.badgeNotification(badgeXml);

Properties

Content Content Content Content

Gets the XML that defines the value or glyph used as the tile's badge.

public XmlDocument Content { get; }public XmlDocument Content { get; }Public ReadOnly Property Content As XmlDocumentpublic XmlDocument Content { get; }
Value
XmlDocument XmlDocument XmlDocument XmlDocument

The object that contains the XML.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The retrieved elements and their attributes are manipulated through Document Object Model (DOM) manipulation functions to customize the badge content. See badge schema for an explanation of badge elements and attributes.

ExpirationTime ExpirationTime ExpirationTime ExpirationTime

Gets or sets the time that Windows will remove the badge from the tile. By default, local badge notifications do not expire and push, periodic, and scheduled badge notifications expire after three days. It is a best practice to explicitly set an expiration time to avoid stale content.

public IReference<DateTime> ExpirationTime { get; set; }public IReference<DateTime> ExpirationTime { get; set; }Public ReadWrite Property ExpirationTime As IReference<DateTime>public IReference<DateTime> ExpirationTime { get; set; }
Value

The date and time that the notification should be removed.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)