語言

BadgeNotificationManager 類別

定義

提供管理應用程式工作列圖示上顯示的徽章通知的方法。

public ref class BadgeNotificationManager sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.BadgeNotifications.BadgeNotificationsContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BadgeNotificationManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.BadgeNotifications.BadgeNotificationsContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BadgeNotificationManager
Public NotInheritable Class BadgeNotificationManager
繼承
Object Platform::Object IInspectable BadgeNotificationManager
屬性

範例

這個範例展示了如何呼叫 SetBadgeAsGlyph 來設定帶有 Alert 字形的通知徽章。

BadgeNotificationManager.Current.SetBadgeAsGlyph(BadgeNotificationGlyph.Alert);

這個範例展示了如何呼叫 SetBadgeAsCount ,以設定數值為 20 的通知徽章。

BadgeNotificationManager.Current.SetBadgeAsCount(20);

這個範例展示了如何將工作列圖示上的徽章與應用程式中的 InfoBadge 控制項同步。 範例:在 導航檢視中遞增數字資訊徽章 以了解代碼。 此程式碼會被加入 MainWindow 該範例的建構子中。 它使用 DependencyObject.RegisterPropertyChangedCallback 方法來監聽屬性的變更 InfoBadge.Value 。

public MainWindow()
{
    this.InitializeComponent();

    mailCountBadge.RegisterPropertyChangedCallback(InfoBadge.ValueProperty, (s, e) =>
    {
        if (e == InfoBadge.ValueProperty)
        {
            BadgeNotificationManager.Current.SetBadgeAsCount((uint)mailCountBadge.Value);
        }
    });
}

備註

通知徽章會傳達應用程式專屬的摘要或狀態資訊。 它們可以是系統提供的字形或數字(1-99)。 若數字徽章值高於99,則顯示為「99+」。

通知徽章會出現在你應用程式的工作列圖示上。 如果應用程式釘選在工作列,即使應用程式未執行,徽章仍會出現。

屬性

名稱 Description
Current

取得目前應用程式的 BadgeNotificationManager 實例。

方法

名稱 Description
ClearBadge()

移除應用程式工作列圖示中的徽章。

SetBadgeAsCount(UInt32)

將指定的整數值以徽章形式套用在應用程式的工作列圖示上。

SetBadgeAsGlyph(BadgeNotificationGlyph)

將指定的字形值以徽章形式套用在應用程式的工作列圖示上。

適用於