BadgeNotification 类

定义

定义更新磁贴锁屏提醒覆盖的内容、关联的元数据和过期时间。 锁屏提醒可以显示 1 到 99 的数字或 状态字形

public ref class BadgeNotification sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.IBadgeNotificationFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
class BadgeNotification final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.IBadgeNotificationFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class BadgeNotification final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.IBadgeNotificationFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class BadgeNotification final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.IBadgeNotificationFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public sealed class BadgeNotification
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.IBadgeNotificationFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class BadgeNotification
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.IBadgeNotificationFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class BadgeNotification
function BadgeNotification(content)
Public NotInheritable Class BadgeNotification
继承
Object Platform::Object IInspectable BadgeNotification
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例代码使用 BadgeNotification 方法创建数字锁屏提醒通知。 如果使用此方法将值设置为“0”,则会清除锁屏提醒。

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);

以下示例代码使用 BadgeNotification 方法创建字形锁屏提醒通知。 如果使用此方法将值设置为“none”,则会清除锁屏提醒。

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);

构造函数

BadgeNotification(XmlDocument)

创建并初始化 BadgeNotification 的新实例。

属性

Content

获取定义用作磁贴锁屏提醒的值或字形的 XML。

ExpirationTime

获取或设置 Windows 从磁贴中删除锁屏提醒的时间。 默认情况下,本地锁屏提醒通知不会过期,推送、定期和计划的锁屏提醒通知会在三天后过期。 最佳做法是显式设置过期时间以避免过时的内容。

适用于

另请参阅