All code for this article can be found here.
Whilst Microsoft’s mobile offering is well and truly dead, their push to provide platform agnostic solutions for developers is alive and well. Xamarin.Forms’ growth has accelerated since Microsoft purchased Xamarin back in 2016 and with .NET Core & .NET Standard providing a simple way to create libraries for all targets easily, C# is becoming a go-to language for creating quality software that scales.
This is why when I first saw tweets from the Uno Platform’s Twitter pop up in my feed I was curious. Uno advertises itself as a framework used to “Build native apps for Mobile and Web using XAML and C#”. This doesn’t sound like anything new especially when talking about the other options we have available for these solutions, but scrolling down on Uno’s site does a stellar job of showing off just what makes Uno a better choice over the competition by providing the following comparison table.
In fact you can try a live sample of a Uno application running in browser here, note they recommend using Firefox or Edge for the best results. This was enough to make me download the quickstart for Uno, I didn’t think that getting started would take long considering they touted XAML Standard/UWP compatibility and I consider myself pretty good with these technologies but it was starting to seem like the whole library was too good to be true.
Opening the solution in Visual Studio, the layout was identical to that of any Xamarin.Forms application. For newcomers, the idea is that your general application code such as pages, page models and 99% of work for your application goes into the shared project whilst any application specific code goes into their related projects. This means that using Xamarin.iOS, Xamarin.Android and the Universal Windows Platform you are able to provide platform specific implementations of various methods which can then be called by a generic interface in the shared project. This process is a bit confusing and one of the big parts of the Xamarin.Forms learning curve so I’m interested to see if Uno improves upon this process at some point. Opening up the main page, I wrote a few methods and created some a ViewModel for the post entities in the JSON Placeholder API (great for this kind of stuff might I add) and I had myself a simple list application.
The first thing that stood out to me was just how fast I was able to get up and running especially when using UWP as my development platform. As noted in the comparison, Uno supports XAML/C# Edit & Continue which basically means that Visual Studio will automatically update the application markup as you type with no reloading or restarting whatsoever. This was an amazing feeling especially when working with
ListView.ItemTemplate which is always a pain to work with as minor changes in Xamarin.Forms would often require a full reload.
Knowing the Uno implements the XAML Standard helps as well, as you can rely on Microsoft Documentation and Code Samples for the Universal Windows Platform when writing these applications. The fact that the solution is treated just as another UWP XAML solution also means the Intellisense that is provided for the XAML files is first class. Data binding auto completion works as expected with
x:bind and tag recommendations and parameter names are always 1:1 with what they should be.
One of other features of Uno that they have been touting is the features they include to facilitate responsive design. By inheriting features of the Universal Windows Platform, Uno implements the State Triggers and Adaptive Triggers which are used in Windows 10 applications. These triggers provide a simple, XAML based way of creating responsive UI for different screens, devices and conditions.
I won’t go into the details of how Visual State Triggers work in UWP, this page does a great job of that, but the good news is once you learn how they work Uno does a great job of facilitating it.
As you can see with UWP/Uno it’s as easy as creating
VisualState definitions which can then edit the properties of
Target element properties by using their
x:Name property (in this case I’m editing the width of my details view column by targeting
ColumnDetails.Width. This means that you don’t have to awkwardly listen for events and set properties of a XAML element based on resource values, it just works. The resulting XAML Markup and C# only requires a few more lines of code for a responsively designed application. Whilst this is achievable in Xamarin.Forms, the simplicity of UWP’s triggers shines in this example.
Uno platform is super promising and whilst it may still need some time to mature there’s definitely no questioning what it can bring to the table. There are definitely some quirks, but considering how early it is in its lifetime and how much it can already do I am hopeful that Uno will become a standard tool of .NET developers everywhere empowering them to write cross platform mobile and web applications that live up to the solid nature of .NET itself.
If you liked this piece please give it a clap, if you’re interested in more from me I’d love a follow too 👌
Create your free account to unlock your custom reading experience.