There are two main options for building applications in .NET and leverage the Windows App SDK, that target multiple platforms (aka cross-platform or multi-platform applications) with is Microsoft’s .NET MAUI and the Uno Platform. Before everyone jumps up and down that I’ve missed Avalonia UI, they don’t fit in this category because they don’t leverage any of the work Microsoft is doing to unify the Windows developer experience with the Windows App SDK and as such not an option that’s being considered. We’re also not going to focus on .NET MAUI for a number of reasons, not the least of which being that it’s not what I’d considered a full implementat of XAML (eg completely lacking the ability to change templates of built in controls). For this reason we’re going to focus on building multi-platform applications with the Uno Platform.
The first thing you need to know is how to get started. Whilst the core of the Uno Platform is a set of NuGet packages, which means you can build an Uno application without any additional third party extensions, there is a Visual Studio Extension which I would definitely recommend as it includes a brand new wizard based experience for creating new apps.
For Visual Studio 2022 I would recommend checking out the Getting Started documentation which will walk you through installing the necessary Visual Studio workloads, running uno-check to validate that the necessary dependencies are installed and to install the Uno Platform Visual Studio Extension.
I’ve already got the necessary components installed for Visual Studio, so I’m going to go to launch the Manage Extensions (from the Extensions menu) dialog and search for Uno Platform.
Click the Download button to install the Uno Platform extension. After it’s downloaded, you’ll need to restart Visual Studio in order for the installation to be completed.
When you restart Visual Studio, you can create a new Uno Platform application by selecting Uno Platform App from the list of templates.
Once you’ve given your application a name and selected the folder where the application should be created, you’ll be taken to the new Wizard based experience for building an Uno Platform application.
The opening screen allows you to pick between two preset configurations, Blank and Default. The Blank preset will create the necessary projects and application structure in order for you to start building an Uno Platform application. However, the Uno Platform offers much more than just the core framework, so by selecting the Default preset your application will be pre-configured to take advantage of things like the Material library, the Toolkit, Extensions for Navigation and MVUX and a host of other features. Feel free to explore the full set of options by clicking on the Customize button – you can start from the Blank template and add options; or you can start from the Default template and customize the options you want.
For the moment we’re going to select the Blank option and hit Create to return to Visual Studio with the newly created application open. You’ll notice that the application has five projects: three platform specific projects for Mobile (iOS, Android, MacCatalyst), Windows, WASM (Web) and GTK, and a multi-targetted class library.
Right-click on any of the projects in the Platforms folder and select Set as Startup Project and then click Run or hit F5 to launch the application on that platform. Note for the Mobile project you’ll need to select between Android and iOS and whether you want to run on a device or via the emulator/simulator.
The core of the application is located in the Class Library (in this case the UnoApp1 project) where you’ll find both the XAML files (for the layout of the application) and code-behind files. Go back to the wizard and create an application using the Default template to see examples of how to wire up an MVVM or MVUX based solution.