Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Windows Community Toolkit 8.0.0 Simplifies Code Portability on Windows Platform

Windows Community Toolkit 8.0.0 Simplifies Code Portability on Windows Platform

Microsoft released version 8.0.0 of the Windows Community Toolkit in September 2023. The updated version unifies the namespaces for both WinUI 3 and UWP code, simplifying the code portability for developers.

The Windows Community Toolkit (WCT) is a collection of controls and libraries that help Windows developers by providing additional features that the underlying platform doesn’t yet offer. Historically, the features provided by the toolkit were gradually incorporated into the Windows development platform itself.

The Windows Community Toolkit is not to be confused with the .NET Community Toolkit (NCT), which contains the common features of WCT that aren’t tied to any underlying UI platform.

The substantial change in version 8.0.0 is the rationalisation and simplification of the toolkit. Up until now, there were two packages in the toolkit: Microsoft.Toolkit.Uwp for the UWP (Universal Windows Platform) and CommunityToolkit.WinUI package for the WinUI 3 platform, supported in WCT since April 2021. In the new version, both platforms will use the CommunityToolkit naming for the packages. Every standalone WCT NuGet package will have two variants, prefixed CommunityToolkit.Uwp for UWP components and prefixed CommunityToolkit.WinUI for WinUI 3 components.

While the packages are named differently, the namespaces inside the code have been unified into CommunityToolkit.WinUI root. This allows developers to change the underlying platform for their applications without having to change any code referencing the toolkit.

To illustrate the new layout of the toolkit, let’s take the HeaderedItemsControl as an example. It is a control that allows items to be displayed under a common header object. A developer will find the new control under the CommunityToolkit.WinUI.Controls namespace in the NuGet package for the headered controls, They would install either the CommunityToolkit.WinUI.Controls.HeaderedControls package or the CommunityToolkit.Uwp.Controls.HeaderedControls package, depending on their development platform.

Beyond the toolkit refactoring and simplification, there are several new features in the updated version. There is a new collection of headered controls (the controls with a common header) and segmented controls (controls that show options from which users can choose). Many controls have been updated visually. The Toolkit Gallery app, a part of the code sample for the WCT, has been updated with a fresh look and now it includes the controls preview and documentation side by side.

The migration process for the users of the old, 7.X version of the WCT involves several steps. The first one is to find whether they were using UWP or Win UI 3 version of the WCT, by looking at the package name in their .csproj file. Microsoft.Toolkit.Uwp is the UWP version, while CommunityToolkit.WinUI is the Win UI 3 version. Those packages will have to be removed and the 8.0 package installed (either the CommunityToolkit.Uwp or CommunityToolkit.WinUI). Then, the code namespace references and XAML namespaces will have to be renamed to CommunityToolkit.WinUI namespace. Microsoft recommends updating the application’s WCT version before trying to switch platforms.

Some features present in the previous version were left out of the 8.0.0 release. The popular AdaptiveGrid control has been replaced with ItemsRepeater control. Microsoft recommends developers check and contribute to the Windows Community Toolkit Labs, a repository for pre-release and experimental features that aren’t stable enough for the main WCT repository. For example, the DataGrid control has been removed from version 8.0.0 and moved into the Labs repository. The feedback from the developers has been generally positive, with some people expressing the disappointment about removal of popular controls.

Version 8.0.0 was pre-released on August 23rd, 2023, and released for general availability on September 7th, 2023. The source code for the toolkit is available on GitHub.

About the Author

Rate this Article