如何在任务栏上设置星号看起来像skype预览应用程序?

时间:2016-12-25 15:23:39

标签: c++ uwp win-universal-app

当我创建一个项目通用应用程序时,我想在任务栏中的图标中添加一个星号,以通知用户某些事件。当收到新消息时它看起来像skype预览应用程序(它将在任务栏上显示一个星号)。 你能帮助我在通用应用程序中设置它(星号)吗?

1 个答案:

答案 0 :(得分:0)

以下代码(来自documentation)应该这样做:

private void updateBadgeGlyph() {
    string badgeGlyphValue = "alert";

    // Get the blank badge XML payload for a badge glyph
    XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

    // Set the value of the badge in the XML to our glyph value
    Windows.Data.Xml.Dom.XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as Windows.Data.Xml.Dom.XmlElement;
    badgeElement.SetAttribute("value", badgeGlyphValue);

    // Create the badge notification
    BadgeNotification badge = new BadgeNotification(badgeXml);

    // Create the badge updater for the application
    BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

    // And update the badge
    badgeUpdater.Update(badge);
}

或者您可以使用NotificationsExtensions,这对创建平铺布局也很有帮助。