Windows Community Toolkit Gets .NET Standard MVVM Library
A new .NET Standard Model-View-ViewModel (MVVM) library heads the list of new features in the Windows Community Toolkit, which just shipped in version 7.0.
A product of the .NET Foundation, the Windows Community Toolkit (formerly called the UWP Community Toolkit) is an open source project providing helper functions, extensions and custom controls designed to simplify and demonstrate common developer tasks when building Universal Windows Platform (UWP) and .NET apps for Windows 10.
Along with the new MVVM library and new controls, other new features include easier-to-use toast notification helpers for both .NET and UWP, and a revamped composition Animation system for C# & XAML.
Michael A. Hawker described v7.0 as one of the project's largest releases as the dev team and community contributors worked to optimize and streamline it for the future.
Its functionality is presented in a sample app that demonstrates (with code) its workings including controls, animations, services, helpers, brushes, extensions and more.
In a March 16 blog post, Hawker described the new MVVM library. The pattern helps foster a clean separation of the business and presentation logic in an application from its UI.
The Microsoft.Toolkit.Mvvm library is modern, fast and modular, Hawker said, following these principles:
- Platform and Runtime Independent: .NET Standard 2.x (i.e. UI Framework Agnostic)
- Simple to pick-up and use: No strict requirements on Application structure or coding-paradigms (outside of 'MVVM' ness), i.e., flexible usage
- À la carte: Freedom to choose which components to use
- Reference Implementation: Lean and performant, providing implementations for interfaces that are included in the .NET Base Class Library, but lacks concrete types to use them directly
Because the library targets .NET Standard, it provides a common API surface that lets it work on UWP, WPF, Xamarin, Uno Platform and others, along with any runtime, including .NET Native, .NET Core, .NET Framework or Mono.
Other highlights of Windows Community Toolkit 7.0 include:
- Improved notification support for Win32 and .NET 5: "Unpackaged Win32 C# apps can now effortlessly use toast notifications, no Start menu shortcut required! Just call the following API, and that is literally it!"
- A new package structure: Refactored packages reduce the number of dependencies that are pulled in for projects with a small number of components. "This has allowed us to reduce the application size footprint impact of the Toolkit in common scenarios by 80-90 percent."
New functionality: including:
- The TabbedCommandBar, an app-level navigation interface that delivers a flexible space to control commanding within an app
- An improved ColorPicker
- A SwitchPresenter, "A new way to layout and organize your XAML. It provides the equivalent of a switch statement from C# in XAML!"
Hawker also noted that the team is shipping toolkit previews hand-in-hand with previews of WinUI 3, a native UX framework for both Windows Desktop (Win32) and UWP applications, which just came out in its fourth and final preview.
As part of that strategy, Hawker said, "We have released a preview of the toolkit which works for Desktop apps with .NET on the Project Reunion 0.5 Preview released last week. Find out more details on how to try this out here."
Microsoft, in announcing the v0.5 preview of Project Reunion, Microsoft said it's being developed because "Windows development is hard."
The idea behind Project Reunion is to alleviate that difficulty, in part by bridging two disparate Windows desktop development schemes that have arisen: Win32 and Universal Windows Platform (UWP). The Win32 API (used for what is often called "classic Windows desktop development") was the original C/C++ platform for native Windows apps, providing close-to-the-metal performance with direct access to system hardware.
"In a few weeks, we will release an updated version of our WinUI 3-based controls to NuGet for Project Reunion 0.5," Hawker said.
Resources for more information about the Windows Community Toolkit include release notes in the GitHub repo and the Windows Developer Center.
About the Author
David Ramel is an editor and writer for Converge360.