Introduction to Uno Platform
This is my first (of hopefully many) blog articles on the Uno Platform, exploring by learning about it. While Uno Platform is not new, has been around for a while, but when I saw an email about this I got intrigued as I am C#/XAML developer of interest. And since I haven’t seen any articles here yet about Uno Platform, I said to myself “Why not?”, so here goes…
What is Uno Platform?
Uno Platform is an open-source, cross platform toolkit that can be used for building applications for not only Windows, but also iOS, Android, macOS, Linux, and the Web. By using a single-codebase that is shareable between all the platforms, a straight-forward way for developers with C# and XAML knowledge to leverage their existing skillset and write an application once; deploy it on any platform; with barely any adjustments or changes. By leveraging XAML, the Uno Platform can render an application’s user interface on all platforms, seamlessly.
Why use Uno Platform?
- Relies on .NET to draw UI on canvas. (iOS, Android, macOS)
- Relies directly on WASM runtime, a part of .NET. (WebAssembly)
- Relies on Skia to draw the UI on canvas. (Linux)
- Allows you to run single-codebase, C# and XAML apps on all these platforms.
- Acts as a bridge for WinUI and UWP apps to run natively on iOS, macOS, Android, Linux and WebAssembly.
- Uno Platform-based applications on iOS, Android and macOS have the exact same, native performance as any other Xamarin-based application.
- For iOS, macOS and Android developers/users, you can deploy Uno Platform built apps as PWAs, deployed like any regular app, through the Apple App Store and Google Play Store.
- For WebAssembly, deploy using GitHub Pages, Azure Web Apps, Azure Static Web Sites, or any other static website hosting provider and CDNs.
- With Uno Platform, you get out-of-the-box support for Visual State Manager, State Triggers, Adaptive Triggers, and more, allowing you to develop responsive applications quickly.
In summary, UWP code runs natively on Windows; however, UWP executes on the Uno Platform allowing it to run on iOS, Android, WebAssembly, and macOS by using Xamarin, .NET, and Mono, respectively.
Now, you’ve read all this and wondering what is WASM and WinUI? I know I was!
What is/Why WebAssembly (WASM)?
WebAssembly allows non-JavaScript code to run in the browser and is one of the four languages endorsed by W3C. Uno Platform uses WebAssembly to run traditional Windows apps in the browser, which provides enormous productivity gains via code and skill reuse.
Also, with Uno Platform being one of the pioneers of WebAssembly (WASM) users in the traditional Microsoft ecosystem, they are the first to market to enable Ahead-Of-Time (AOT) and porting many traditional Windows-based apps and developer productivity tools to the Web.
What is WinUI?
Windows UI Library (WinUI) is the future of building applications for Windows and is a successor to great technologies such as WinForms, WPF and UWP. The Windows developer ecosystem has a great ecosystem of 1st and 3rd party components and is familiar to hundreds of thousands of C# and XAML developers who want to leverage that exact same skill set to build not only future Windows applications but apps for iOS, Android, macOS, Web and Linux.
What’s More?
- Pixel-perfect Control / SkiaSharp
- No Xamarin.Forms Dependencies
- All Browsers via WebAssembly (https://github.com/unoplatform/Uno.Wasm.Bootstrap)
- Can be utilized with your preferred IDE of choice: Visual Studio (Windows, Mac); Visual Studio Code or JetBrains Rider.
- Free and Open-source
Pixel-perfect multi-platform apps with WinUI, XAML, and C#: Pixel-perfect means that the applications looks the same on different platforms. By default, Uno Platform uses UWP/WinUI platform 2D directives to draw the UI. Essentially, stripping the native controls of their chrome, keeping their behaviors exclusively and draw everything. Uno Platform does the heavy lifting for pixel-perfect look depending on the targeted platforms, with the use of either the underlying platform 2D primitives to render same UI everywhere or use Skia to draw every pixel.
Building multi-platform with a Single code-base: Define a user interface and your application logic only once, and Uno Platform makes it automatically work on different target platforms beyond Windows, for example, Android, iOS, and the Web.
No Xamarin.Forms Dependencies: For those of you used to Xamarin.Forms, Uno Platform enables you to run your Xamarin.Forms apps in browsers via WebAssembly. Both Uno and Xamarin.Forms are built on top of the Xamarin Native stack. Xamarin.Forms runs on UWP via the Windows.UI.XAML APIs and the Uno Platform is an implementation of the UWP (and future WinUI) APIs.
Finally…
When you create your Uno Platform’d project, you have Shared Project that is XAML and C#, which is actually WinUI-specific code, with the UIElement class that inherits from Dependency Objects. However, WinUI code does not work directly in an iOS or Android project. The Uno Platform makes the WinUI code that you write in the Shared Project work on all the different targeted platforms beyond Windows by mirroring the WinUI types. For iOS projects, the UIElement class inherits from the UIView class; For macOS projects, the UIElement class inherits from NSView class; For Android projects, the UIElement inherits from the Android-specific ViewGroup class; For Linux projects, a tool called Skia, an open-source 2D graphics library, is used to draw the user interface on a canvas; For the Web, a transformation from XAML to HTML is required, where each XAML element is mapped to an HTML element, allowing your native web applications to run in all browsers.
Uno Platform has an Uno WinUI library that contains framework features that are shared across all platform-specific projects. Shared features such as data binding, style and resource resolution and dependency properties, existing in the XAML UI frameworks like WinUI and WPF.
In my opinion…
I’m a VB/C#/ASP.NET developer, and I’m really psyched to give this Uno Platform a try and explore all it’s capabilities and what more it has to offer.
My next article will be a tutorial where I will introduce you how to set up Uno Platform and creating your first application.
Subscribe to my newsletter
Read articles from Ronica Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Ronica Singh
Ronica Singh
I am a Software/Web Developer from Durban, South Africa. I have been interested in web development for many as I saw that as a growing technology that will never end. My interests expanded to Game development when I learned that I can make games with HTML5 Canvas. I love coding games more than drag and drop features. I can't remember what got me interested in making games. I love teaching others programming, web skills and more about making games, that is game development and game design. I am now teamed up with a woman in Nigeria, actually from Benin, to start our own gaming studio and make games for change. Our first in our games production will be a series of games teaching players about climate change and how we can help improve the circumstances we find ourselves in.