Last Updated on 2022-07-15 by James Croft

What do you do when you have an awesome control you built for the Universal Windows Platform that you want on other platforms? Spend an evening getting it up and running with the Uno Platform of course!

What is the Uno Platform?

In its simplest terms, the Uno Platform is the only bridge you need between your existing UWP codebase and other platforms. It redefines the term ‘universal’ bringing your Windows application to Android, iOS, Linux, macOS, and the web!

The pixel-perfect mantra from Uno also means that you only really need to focus on the development of your UWP application. As you develop, the time to code, debug, test, and refactor is drastically reduced on the other platforms.

You also use the skills you already know. As a UWP developer myself, I don’t have to go and learn how to build UI and use APIs for other platforms. I only need to care about what I can do with UWP.

Migrate to new SDK-style project

If you’re already using the new SDK-style project format for your UWP libraries, porting is a breeze. Skip down to Adding Uno Support to get ahead!

Migrating your existing UWP library to the new SDK-style project format is relatively straightforward.

In order to get started, we’ll be using the MSBuild SDK Extras package which brings in support for additional target frameworks like UWP. If you want to learn more on this, check out my post on enhanced multi-targeting with .NET Standard.

You will first need to add a global.json file at the root of your solution. This allows you to define which .NET SDK version is used when you run .NET CLI commands. As we will be using the MSBuild SDK Extras here, that’s what we define in this file.

Now let’s get to your UWP project file. Either unload your project in the solution file, or even easier, open the folder for your project in Visual Studio Code! Your UWP project should look something like this.

This simply converts into the SDK-style project format as below.

This new project format, taking advantage of the MSBuild SDK Extras library, is now ready to take cross-platform with Uno!

Adding Uno Platform support

The first step to adding Uno Platform support is just a couple of modifications to your new project file.

Supporting additional target frameworks

First, you want to change your TargetFramework tag to TargetFrameworks and add the additional platforms you wish to support. I’d recommend adding Android, iOS, macOS, and the .NET Standard 2.0 frameworks.

You’ll also want to add a package reference to the Uno.UI NuGet package. This only needs to be added for the additional frameworks, not your chosen UWP version. You can add this with a conditional ItemGroup in your project file.

Here’s what this would look like following on from the previous examples.

Updating custom controls

If your library contains custom controls or objects that inherit from a DependencyObject, you’ll need to add the partial keyword. The reason for this is that Uno generates some additional compile-time code to support these components.

If you come upon any other issues now that you’ve ported over your UWP library to Uno, I’d recommend checking out Uno’s guidance to check for additional changes.

Good to go!

If your experience is anything like mine was, you’re now good to go! You might want to do some testing of your own with your controls on the new platforms you added support for.

Download the Uno Platform Solution Templates for Visual Studio to get started with this. With this extension, you can quickly create a new Uno application to validate your changes on iOS, macOS, Android, and the web.

Once created, simply add your project reference to all of the application projects. Then hit run and see the magic for yourself!

MADE.NET InputValidator UWP control running on the web
MADE.NET InputValidator UWP control running on the web

If you want to check out what this all looks like in a real project, check out MADE.NET on GitHub. I recently updated the InputValidator control to support Uno and have sample applications showcasing it running on supported platforms.

Found this article useful?

Thank you for taking the time to read this article. I’m committing to sharing more of my knowledge through my blog and open-source projects! You’ll also catch me in casual conversation on Bluesky and LinkedIn too.

If you enjoy what you see, please consider subscribing to get a notification when new articles go live!

Go further with the Uno Platform

Uno Platform is an open-source project, publicly developed on GitHub. I highly recommend contributing back to the project to further improve it.

Although the Uno Platform ensures that your application or library can still build and run by providing the Windows SDK types, some of these are not currently implemented.

You can find a lot of these on their issue tracker, and if not, why not open a new issue. You could even look at implementing support for one or all of the platform!


Discover more from James Croft

Subscribe to get the latest posts sent to your email.

James Croft

James is a senior software engineer at Microsoft with over 10 years experience designing and building large-scale, distributed, cloud-native systems. He's deeply experienced in C#, Python, and TypeScript, with specialization in AI agent architectures, retrieval-augmented generation (RAG), and production-grade Azure systems.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.