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 BadgeNotification : IBadgeNotificationpublic sealed class BadgeNotification : IBadgeNotificationPublic NotInheritable Class BadgeNotification Implements IBadgeNotification// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following example code uses the BadgeNotification 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 BadgeNotification 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 BadgeNotification(XmlDocument content)Public Sub New(content As XmlDocument)// You can use this method in JavaScript.
Parameters
content
XmlDocument XmlDocument XmlDocument XmlDocument

The XML content that defines the badge update.

Examples

The following example code uses the BadgeNotification 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);

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.

See Also

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 XmlDocument// You can use this property in JavaScript.
Value
XmlDocument XmlDocument XmlDocument XmlDocument

The object that contains the XML.

Remarks

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

See Also

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 Nullable<DateTimeOffset> ExpirationTime { get; set; }Public ReadWrite Property ExpirationTime As Nullable<DateTimeOffset>// You can use this property in JavaScript.
Value
IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset> Nullable<DateTimeOffset>

The date and time that the notification should be removed.

See Also

See Also