Create a new WinUI 3 and Uno Platform app
Uno Platform apps can be created in both UWP-compatible (Windows.UI.Xaml
, also known as WUX) and WinUI 3-compatible (Microsoft.UI.Xaml
, also known as MUX) flavors. In the latter case, you can use the latest features of .NET 5 and WindowsAppSDK (formerly known as "Project Reunion") for WinUI 3 Desktop apps. This article takes you through the steps of creating a WinUI 3-flavored Uno Platform app and running the app with WindowsAppSDK for Desktop.
Prerequisites
- Visual Studio 2019 16.10 preview 1 or higher (for Live Visual Tree, Live Property Explorer and XAML Hot Reload), with following workloads installed:
- Universal Windows Platform development
- .NET desktop development
- .NET SDK (.NET 5 or higher)
Set up your environment
- Install the Uno Platform dotnet templates. From a command-line prompt, run the following command:
dotnet new -i Uno.ProjectTemplates.Dotnet
Create a new app
- Create a folder for your app.
- From a command-line prompt at that folder location, run the following command:
dotnet new unoapp-winui -o MyUnoApp
- Open the solution file you created.
- UI Tooling features (Live Visual Tree, Live Property Explorer, and Hot Reload) for WinUI 3 need to be enabled in Visual Studio as a Preview Feature. Navigate to
Tools -> Options -> Environment -> Preview Features
and toggle "Enable UI Debugging Tooling for WinUI 3 Projects". - To debug the WinUI 3 Desktop project, set
[MyAppName].Windows.Package
as the startup project, set the Solution Platform tox86
, and run the application.
Create a new app with .NET 6
- Create a folder for your app.
- From a command-line prompt at that folder location, run the following command:
dotnet new unoapp-winui-net6 -o MyUnoApp
- To debug the WinUI 3 Desktop project, set
[MyAppName].Windows
as the startup project, set the Solution Platform tox86
, and run the application.
Note that this project template comes with two packaging flavors (packaged or unpackaged). Depending on the one you will choose, you'll need to adjust these properties (WindowsAppSDKSelfContained
or SelfContained
).
If the application is started in an mismatched configuration, you'll get this runtime error:
System.DllNotFoundException: 'Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found.