Blog

Avalonia UI: Introduction and Initial Impression

Avalonia UI: Introduction and Initial Impression

Avalonia UI is an open-source UI framework for cross-platform, .NET applications. It is free to use under the MIT license, and it supports Windows, macOS, Linux, iOS, Android, and WebAssembly. The framework is owned by the commercial entity, AvaloniaUI OÜ, and it is maintained by a community of developers and a core team of around twenty that work full-time for the company. 

Avalonia is a “spiritual successor” to WPF which gives developers a familiar experience. You can code in C#, F#, or XAML for Avalonia’s UI, and you can use different IDEs such as Visual Studio, Visual Studio Code, and JetBrains Rider, but JetBrains Rider is the IDE Avalonia recommends for development. 

A Brief History of Avalonia UI 

Avalonia had its first commit in December of 2013 when it was still called Perspex. Although Avalonia has been around for over a decade, it started gaining more popularity in 2020 when it joined the .NET Foundation. The partnership with .NET Foundation was short-lived though, and Avalonia left it in February of 2024

Avalonia XPF 

Along with the open-source, free to use, UI framework, the AvaloniaUI OÜ company also sells licenses to Avalonia XPF

Avalonia XPF is a cross-platform fork of WPF, and it allows developers to “instantly” make a cross-platform version of their WPF project. It does this by leaving presentation core and presentation framework untouched so the WPF application “just works”. If the project has other Windows dependencies outside of WPF though, it may need additional massaging to migrate those features. For example, if your project only targets .NET Framework, which is Windows specific, updates will be needed to allow it to work cross-platform. 

Initial Impression 

Overall, Avalonia feels like a modern version of WPF, and it cleans up some of WPF’s quirks. 

If  you are familiar with WPF, the ramp up time to Avalonia is fairly quick. The largest differences are getting used to Avalonia’s styling and learning the different UI controls and their properties. 

For developers that are new to both WPF and Avalonia, it’s likely that it would take about the same amount of time to learn either framework. The documentation for WPF is much more extensive since it’s been around longer, but a lot of it can also apply to Avalonia. Conversely, Avalonia has fewer resources, but the resources that are available are better organized and modernized. The documentation to get started with Avalonia can be found here

Support 

Avalonia releases updates consistently which can give developers peace of mind that it is maintained well. It supports .NET Framework 4.6.2+, .NET Core 2.0+, and .NET 5+. 

When using the Model-View-ViewModel (MVVM) pattern, Avalonia works well with the ReactiveUI and MVVM Community ToolKit libraries. This is great news since WPF also supports these libraries. 

IDEs 

As a WPF developer that already has a Visual Studio license, VS is my go-to IDE, and there is an Avalonia Extension for Visual Studio 2022. Although this extension exists, it is a bit lackluster. It does not support the code completion nor the rich syntax highlighting for AXAML (Avalonia’s flavor of XAML) files that you would typically expect for XAML files. These deficiencies can cause a slower or less enjoyable developer experience. 

Visual Studio Syntax Highlighting
Visual Studio Syntax Highlighting 

The IDE Avalonia recommends is JetBrains Rider. Rider is free only for non-commercial use. This IDE makes programming in Avalonia much smoother as it does support code completion and syntax highlighting for AXAML. It also supports more obvious highlighting for file types, and its IntelliSense code “usages” feature finds references in both C# and AXAML files.

JetBrains Rider Syntax Highlighting
JetBrains Rider Syntax Highlighting 

Unfortunately, Avalonia does not support hot reload at all, but it does have an AXAML design previewer which is similar to the XAML Live Preview. 

AXAML Design Preview
AXAML Design Preview 

Cross-Platform Demo 

To demonstrate the look and feel of Avalonia on different platforms, I followed the Avalonia Music Store App tutorial and deployed it to a Windows and Linux operating system respectively. 

Avalonia on Windows
Windows 

Avalonia on Linux
Linux

As you can see, the application looks consistent across different platforms thanks to Avalonia’s independent rendering. Avalonia does not rely on the native UI controls of the operating system. Instead, it draws the entire UI itself which allows for more flexibility and customization. 

Takeaways 

Avalonia is a great option to have for desktop development, especially for cross-platform use cases. Avalonia’s styling features and components streamline development while also providing a similar feel to WPF. While Avalonia seems like WPF 2.0, WPF is still a strong choice for Windows platforms. WPF has a long history of development behind it and many resources available that have led it to be DMC’s standby for a long time. 

At DMC, we are always looking towards the future and learning new technologies to better support the wide variety of needs our customers have. We are excited to continue exploring Avalonia UI to provide expert solutions for cross-platform, desktop development. 

Ready to take your Application Development project to the next level? Contact us today to learn more about our solutions and how we can help you achieve your goals. 

Comments

There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts