Today, the Uno Platform is adding support for WinUI 3.0 Preview, alongside WinUI 2/UWP and later. This allows applications to use newer APIs from Microsoft and create cross platforms apps. We’ve worked closely together with the WinUI team in order to be able to bring you Uno Platform 3.0 release at the same time WinUI 3.0 Preview 1 is being announced at Microsoft Build 2020 conference.
With the approach of keeping both API sets active with two nuget packages (Uno.UI and Uno.WinUI), we’re making sure that we’re not breaking existing applications, while enabling experiments with WinUI 3.0 Preview 1.
About Uno Platform
For those new to Uno Platform – it enables for creation of single-source C# and XAML apps which run natively on iOS, Android, macOS and Web via WebAssembly. (or #WinUIEverywhere). Uno Platform is Open Source (Apache 2.0) and available on GitHub. To learn more about Uno Platform, see how it works, or create a small sample app.
Sample Uno Platform App with Source Code – Ch9
To showcase the power of WinUI and Uno Platform in a cross-platform setup, we created a small app which consumes videos from publicly available Channel 9 RSS feed – about 40 most recent videos and we are planning to show all available content soon. The app is available in App Stores (Windows Store, Apple AppStore, Google Play), and you can see its source code on GitHub. Current features are show listings & video playback, dark mode and device orientation changes. More features are coming as we improve this WinUI & Uno Platform showcase app.
Customer Showcase – Chorus Software Solutions
Encore Support Services, a leading organization in the autism behavioral health industry, partnered with Chorus Software Solutions to solve significant operational challenges and practitioner burnout. Chorus, a Microsoft partner leveraging Azure, CDS, the Power Platform and the D365 Health Accelerator was intrigued by the Uno platform and WinUI tie-in to create an intuitive mobile and desktop apps to support Encore’s clinicians and impact quality care.
Creating a WinUI 3.0 app with Uno Platform support
We’re already providing a set of command line templates to create blank applications, and we’re adding a new one to target the WinUI 3.0 API set.
To create a new app:
- Install the dotnet new Uno templates:
dotnet new -i Uno.ProjectTemplates.Dotnet::3.0.0-dev.22
- Create a new app:
dotnet new unoapp-winui -o MyWinUIApp
Deep Dive
The upgrade to WinUI 3.0, from a consumer perspective, is a simple “find and replace” to target the newer APIs. Migrating an application from UWP to WinUI 3.0 requires a few namespaces to be changed:
- Windows.UI.Xaml becomes Microsoft.UI.Xaml
- Windows.UI.Composition becomes Microsoft.UI.Composition
A few other changes like the Uno.UI nuget packages:
- Uno.UI becomes Uno.WinUI
- Uno.UI.RemoteControl becomes Uno.WinUI.RemoteControl
- Uno.UI.Lottie becomes Uno.WinUI.Lottie
- Uno.UI.DualScreen becomes Uno.WinUI.DualScreen
A few other changes need to be made to the UWP head, such as adding:
<PropertyGroup> <WindowsXamlEnableOverview>true</WindowsXamlEnableOverview> <IsWinUIAlpha Condition="'$(IsWinUIAlpha)' == ''">true</IsWinUIAlpha> <WindowsKitsPath Condition="'$(IsWinUIAlpha)' == 'true'">WinUI-Alpha-Projects-Don-t-Use-SDK-Xaml-Tools</WindowsKitsPath> </PropertyGroup> <ItemGroup> <PackageReference Include=""Microsoft.WinUI""> <Version>3.0.0-alpha.200210.0</Version> </PackageReference> </ItemGroup>
Those changes are already part of the unoapp-winui template.
In Uno itself, we’ve taken the approach of keeping the repository under the Windows.UI.Xaml, as most of the current code will continue using it, then have a Continuous Integration job do the conversion work to the Microsoft.UI.Xaml namespace.
This approach makes it easier to debug existing applications without having to transform the Uno source tree to the new namespaces.
This way, we get to keep both Uno.UI and Uno.WinUI synchronized for a while until WinUI 3.0 is released. Once WinUI 3.0 is officially released, we’ll migrate the source tree over to WinUI 3.0.
You can see our official Press Release here, alongside quotes from our partners on WinUI Team.
Jerome Laban, CTO, Uno Platform, on behalf of Uno Platform team.