Freigeben über


NotificationsExtensions has moved to the UWP Community Toolkit!

The UWP Community Toolkit is a new open-source library that enables the developer community to collaborate and contribute new capabilities on top of the Windows SDK, including new controls, API's, and helpers for the existing SDK.

We have moved NotificationsExtensions (our helper object model for constructing XML Tile and Toast notifications) into the UWP Community Toolkit, so that the UWP Community Toolkit can become the single source for the most common and helpful libraries.

What does this mean?

  • The NotificationsExtensions NuGet package is being deprecated. Please switch to the Microsoft.Toolkit.Uwp.Notifications NuGet package for all future development.

  • The NotificationsExtensions GitHub repo is being deprecated. The code has been transitioned into the UWP Community Toolkit GitHub, where all future improvements will be made. Please submit any issues or pull requests on that new repo.

Migrating to the new library

We wanted to make sure the transition is as easy as possible, so we avoiding making any major changes from the most recent version. However, we have removed the deprecated classes and properties to keep the API surface as clean as possible. If you were using an old version of NotificationsExtensions, you might have been using some of the deprecated classes, and there might be some changes.

New NuGet package

Uninstall the current NuGet, and install the new UWP Community Toolkit Notifications NuGet package, which you can find by searching "uwp notifications", or using the full NuGet package ID: Microsoft.Toolkit.Uwp.Notifications.

New namespace

Previously, we had separate namespaces for Tile and Toast (and the generic namespace for shared content). Now, this is all converged under a single Notifications namespace inside the UWP Community Toolkit.

 
using Microsoft.Toolkit.Uwp.Notifications;
 
using NotificationsExtensions;
using NotificationsExtensions.Tiles;
using NotificationsExtensions.Toasts;

Breaking changes before version 14332.0.0

If you weren't using version 14332.0.0 or higher of NotificationsExtensions, read this previous blog post that discusses the breaking changes made in that version, which also apply to the UWP Toolkit version. You will need to address those changes first.

Breaking changes post-14332.0.0

We removed all of the deprecated classes and properties when switching to the new library. That means no more ToastText and TileText, since that becomes a shared AdaptiveText. That also means ToastVisual no longer has TitleText and other properties... it just has BindingGeneric now.

Here is an example of a Toast, and the changes required if you were using the deprecated classes/properties (Tiles will also require converting the respective TileText and TileImage/TileGroup/TileSubgroup elements into AdaptiveText/AdaptiveImage/AdaptiveGroup/AdaptiveSubgroup).

 
ToastVisual visual = new ToastVisual()
{
    BindingGeneric = new ToastBindingGeneric()
    {
        Children =
        {
            new AdaptiveText()
            {
                Text = title
            },
 
            new AdaptiveText()
            {
                Text = content
            },
 
            new AdaptiveImage()
            {
                Source = image
            }
        },
 
        AppLogoOverride = new ToastGenericAppLogo()
        {
            Source = logo,
            HintCrop = ToastGenericAppLogoCrop.Circle
        }
    }
};
 
ToastVisual visual = new ToastVisual()
{
    TitleText = new ToastText()
    {
        Text = title
    },

    BodyTextLine1 = new ToastText()
    {
        Text = content
    },

    InlineImages =
    {
        new ToastImage()
        {
            Source = image
        }
    },

    AppLogoOverride = new ToastAppLogo()
    {
        Source = logo,
        Crop = ToastImageCrop.Circle
    }
};