One portion of .NET Framework which didn’t find a way to .NET Core is a UI framework. Neither WinForms nor WPF are part of .NET Standard or supported by .NET Core. They are tightly coupled with Windows and may need significant rework to become available on other platforms. To fill the gap and fight the dominance of JavaScript and Electron in cross-platform development, .NET community started Avalonia project – a cross-platform UI framework inspired by WPF and running on top of .NET Core. Last week Avalonia project announced Beta release, so it is a good time to try it to see what it can do.

Overview

Avalonia is inspired by WPF but it does not try to stay compatible with WPF or any other XAML stacks. The project uses own dialect of XAML, with the biggest difference in a way it handles styles. It is not only dropped the idea of resource dictionaries, but also uses CSS-like concept of selectors for applying styles.

This is an example how the simple window and a styled control look like with Avalonia. Looks familiar, but there are twists to make WPF developers confusing from time to time. Experience with CSS will definitely be helpful to catch the new concepts.

This code works on top of .NET Core, allowing development of desktop applications for Windows, Linux and macOS. Based on the execution platform, Avalonia uses different platform-specific implementations and rendering engine.

Usage

Getting started is extremely easy. There is a Visual Studio extension which adds Avalonia templates to VS and brings visual designer for Avalonia XAML.

New Avalonia project

Alternative approach is to use Avalonia templates for .NET Core and create new application via dotnet new command.

Build generates a normal .NET Core project which can be deployed as any other .NET application. For a simple application development experience is surprisingly smooth. Now it is time to try Avalonia with a larger project to understand the gaps and any issues with running the app on different platforms.

blog comments powered by Disqus