コード例 #1
0
        private void BuildNotifications(IList <Notifications> notifications)
        {
            List <Notifications> filteredNotifications = notifications.Where(n => !n.content.StartsWith("You")).ToList();
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            badgeUpdater.Clear();
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.EnableNotificationQueue(true);
            tileUpdater.Clear();
            BadgeNumericContent badgeContent = new BadgeNumericContent((uint)filteredNotifications.Count);

            badgeUpdater.Update(new BadgeNotification(badgeContent.GetXml()));
            ToastNotificationManager.ConfigureNotificationMirroring(NotificationMirroring.Allowed);

            // Keep track of the number feed items that get tile notifications.
            int itemCount = 0;

            // Create a tile notification for each feed item.
            foreach (var notification in filteredNotifications)
            {
                // Create a new tile notification.
                tileUpdater.Update(new TileNotification(GenerateTileContent(notification).GetXml()));
                ToastNotification toastNotification = new ToastNotification(GenerateToastContent(notification).GetXml());
                ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
                // Don't create more than 5 notifications.
                if (itemCount++ > 5)
                {
                    break;
                }
            }
        }