BadgeNotification 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
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
- 繼承
- 屬性
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 將移除磚徽章的時間。 根據預設,本機徽章通知不會過期,且推播、定期和排程徽章通知會在三天后到期。 最佳做法是明確設定到期時間以避免過時的內容。 |