BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News An Early Look at Avalonia, a Cross-Platform UI Toolkit for .NET

An Early Look at Avalonia, a Cross-Platform UI Toolkit for .NET

Leia em Português

This item in japanese

Bookmarks

An often-cited hole in the .NET Core ecosystem is the lack of any true cross-platform UI toolkit. While there have been attempts at a multi-platform toolkit in the past, such as Silverlight and Xamarin Forms, no one has yet achieved a full XAML-style cross-platform option. Avalonia is making the attempt with plans to support Windows (.NET Framework, .NET Core), Linux (GTK), MacOS, Android and iOS.

Although the principle inspiration is Windows Presentation Foundation (WPF), this is not a direct port of that toolkit. Some key changes are being made in the design, such as how styles work. In Avalonia, styles work more like CSS with style classes and selectors being able to cascade and overlap. By contrast, WPF only allows a single style per control. This means Avalonia should be able to reduce the need for duplicative styles.

Rather than triggers, Avalonia uses pseudo-classes such as ":pointerover" for hover effects. Other pseudoclasses include :focus, :disabled, :pressed for buttons, :checked for checkboxes etc.

Avalonia styles can only be bound to a StyledProperty. This is analogous to WPF's DependencyProperty with the same basic pattern. Attached properties are also supported. (This come into play with layout controls such as a grid needing to know where its children want to be placed.)

An interesting feature of Avalonia's data binding syntax is support for asynchronous operations. For example, Avalonia can bind to the result of a Task<T> or IObservable<T> operation, which is not supported in other XAML-based UI toolkits.

While a lot of progress has been made, only three developers are doing most of the work. Accordingly, they are calling upon the greater open source community to pitch in where they can. According to Jeremy Koritzinsky, the areas that they most need assistance in are:

Documentation

Mostly conceptual documentation, tutorials, how-to guides.

Demo Apps

Making WPF-like tutorial applications in Avalonia and highlighting any differences they find.

XAML expert

Helping us with our more advanced XAML constructs such as conditions and adaptive layout (like how Xamarin.Forms has some level of adaptive layout)

Common controls we're missing

DataGrid: We know we need it, but it's tons of code that we just don't have time to port right now (every WPF or UWP implementation nears LOC equal to all of Avalonia as of now)

2D Graphics expert

Specifically for proper text layout/rendering on our non-DirectX rendering subsystems. We use Skia on non-Windows platforms, and they lack a text layout engine.

Visual Studio Extension

Upgrading our extension to our new designer, XAML intellisense.

Avalonia is being developed on GitHub under the MIT License.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT