0

我正在创建一个 Windows 10 应用程序。我需要在动态磁贴中显示徽章。我安装了 NotificationsExtensions.Win10 Nuget 包。我使用以下代码。

  public static void UpdateTileBadgeNumberUsingNotificationExtensions()
    {
        BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);
        BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
    }

这里 CreateNotification 方法在徽章内容上不可用。如何使用 NotificationsExtensions.Win10 Nuget 包实现徽章计数。

4

2 回答 2

1
  var badge = new BadgeNumericNotificationContent(2);
        XmlDocument bdoc = content.GetXml();
        BadgeNotification bnotification = new BadgeNotification(bdoc); 
        BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(bnotification);
于 2016-05-30T13:59:19.877 回答
0

请按如下方式更新您的代码:

 BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);
 BadgeNotification bnotification = new BadgeNotification(badgeContent.GetXml());
 BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(bnotification);

创建新BadgeNumericNotificationContent实例后,您将获得一个内容。您需要GetXml()从此内容调用并将 xml 文档设置为BadgeNotification实例。然后您可以通过 更新徽章BadgeNotification

于 2016-05-31T10:13:23.413 回答