BadgeNotification 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 : IBadgeNotification
struct winrt::Windows::UI::Notifications::BadgeNotification : IBadgeNotification
public sealed class BadgeNotification : IBadgeNotification
Public NotInheritable Class BadgeNotification Implements IBadgeNotification
var badgeNotification = new badgeNotification(content);
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) BadgeNotification(XmlDocument)

Creates and initializes a new instance of the BadgeNotification.

Properties

Content Content Content Content Content

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

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

See Also