BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Avalonia Beta 1 Brings Many Improvements over WPF

Avalonia Beta 1 Brings Many Improvements over WPF

This item in japanese

Bookmarks

Avalonia describes itself as a "cross platform .NET UI framework inspired by Windows Presentation Framework (WPF), with XAML, data binding, lookless controls and much more." Having just reached its first public beta, it is already showing some interesting improvements over the venerable WPF version of XAML.

One of the major annoyances of traditional XAML development is the need to create ICommand objects. Unless you need the CanExecute functionality, an ICommand is essentially just a wrapper around a normal method. The construction of these objects often results in a lot of otherwise unnecessary boilerplate code in view-models. Even worse, data models have to either expose this UI-centric concept or be hidden behind a view-model style proxy.

Avalonia offers a rather obvious and easy fix -- commands on user controls can be directly data-bound to methods. ICommands are still supported when needed, but most of the time they can be ignored.

Another time saver offered by Avalonia is syntax support for relative sources. Rather than the lengthy "{Binding Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Border} AncestorLevel=1}}" you can write "{Binding $parent.Text}".

New Previewer Architecture

Since Avalonia is meant to be cross-platform, it needs developer tools that are likewise cross-platform. Once such tool is the new previewer architecture. Like the Language Server Protocol used by .NET, the previewer will run as a separate process. By default, it will present the IDE with a rendered bitmap transferred via TCP: "The AvaloniaVS extension has already been updated to use this new protocol, and hopefully now designers for other IDEs will be coming soon!"

Getting Started

If you are using Visual Studio on Windows, the Avalonia for Visual Studio extension provides the necessary tools and project templates. For other platforms, you can use the Avalonia templates for .NET Core.

Avalonia is released under the MIT license and Avalonia is looking for developers who can contribute time to the project.

Rate this Article

Adoption
Style

BT