Open Sourcing XAML Behaviors for WPF
Today, we are excited to announce that we are open sourcing XAML Behaviors for WPF.
In the past, we open sourced XAML Behaviors for UWP which has been a great success and the Behaviors NuGet package has been downloaded over 500k times. One of the top community asks has been to support WPF in the same way. XAML Behaviors for WPF now ships as a NuGet package – Microsoft.Xaml.Behaviors.Wpf . This will allow new features and bug fixes to be addressed faster. When a new Behavior or feature is added to the repo, it can be consumed and used almost immediately. Opening to contributions lets the Behaviors platform grow by empowering the community to set the pace and direction. While you can continue to use the Extension SDK, further development will only take place on GitHub and be published in the NuGet package under the new namespace Microsoft.Xaml.Behaviors.
Start using XAML Behaviors for WPF now!
You can install the latest version of WPF XAML Behaviors in both Visual Studio and Blend using the NuGet Package Manager:
From the package manager console:
PM > Install-Package Microsoft.Xaml.Behaviors.Wpf
From Blend Assets pane:
Like UWP, we have made updates to Blend for Visual Studio 2019.Instead of presenting a pre=populated list of Behaviors in the Assets Pane, Blend prompts the user with a link to install the NuGet Package. Clicking this link will download and reference the latest NuGet Package and populate the list with the latest and greatest Behaviors. Note that if this is an existing project which references the old Behaviors SDK, the list will be pre-populated with the Behaviors from the SDK. See below for steps to migrate to the NuGet package.
Migrating .NET Framework projects from Extension SDK to NuGet
The NuGet package ships with DLLs under the “Microsoft.Xaml.Behaviors” namespace. Since the APIs for WPF are the same as the original Extension SDK, switching over is as easy as installing the NuGet package and updating the xmlns and the usings. Note that Behaviors are not yet fully supported on .NET Core.
Steps to migrate:
- Remove reference to “Microsoft.Expression.Interactions” and “System.Windows.Interactivity”
- Install the “Microsoft.Xaml.Behaviors.Wpf” NuGet package.
- XAML files – replace the xmlns namespaces “http://schemas.microsoft.com/expression/2010/interactivity” and “http://schemas.microsoft.com/expression/2010/interactions“with “http://schemas.microsoft.com/xaml/behaviors“
- C# files – replace the usings in c# files “Microsoft.Xaml.Interactivity” and “Microsoft.Xaml.Interactions” with “Microsoft.Xaml.Behaviors”
A big thank you to our MVP leaders for dedicating their time and effort in helping guide this project as WPF XAML Behaviors are opened to the community.