DEV Community

Nishtha Singh
Nishtha Singh

Posted on

Check out Avalonia, a Cross-Platform User Interface Toolkit for the .NET Core

An often-cited hole in the ecosystem of .NET Core is the lack of any true cross-platform user interface or UI toolkit. Although there have been attempts on a multi-platform toolkit before, like Xamarin and Silverlight forms, no one has yet achieved full XAML-style cross-platform option. Avalonia makes the attempt with plans of supporting Windows .NET and .NET Core, MacOS, Linux, Android and iOS.

While the principle inspiration is the WPF or the Windows Presentation Foundation, this isn’t a direct port of the toolkit. Some major change are made in the design, which include how styles work. With Avalonia, styles work more like CSS, with selectors and style classes being able to cascade and overlap. In contrast, the Windows Presentation Foundation only enables a single style per control. Meaning that Avalonia must be able to minimize the need for duplicative styles. Instead of triggers, Avalonia uses pseudo-classes, like ‘.pointeroer’ for hover effects. Other pseudo classes are :disabled, :focus, :pressed for buttons, :checked for checkboxes and others.

The styles of Avalonia could be bound only to a StyledProperty. This is analogous to the DependenyPropety of WPF with the same basic pattern. Attached properties also are supported.

An interesting feature that developers of an Asp.Net development company will find interesting indeed is the data binding syntax. A support for asynchronous operations. For instance, Avalonia could bind to the result of a Task or IObservable operation that is not supported in other XAML-based user interface toolkits.

Avalonia UI for .net Core

CONTRIBUTIONS FROM A BIGGER OPEN SOURCE COMMUNITY

Although a lot of progress has been made, there are only three developers doing most of the work. Accordingly, they’re calling on the bigger open source community to pitch in where they can. Developers, those working in a .NET software company or even those working freelance could all chip in and contribute.

AVALONIA IN THE ALPHA STAGE

Avalonia is in alpha now. This means that the framework now is a stage where one could have a play and create simple apps hopefully. There’s still a lot missing, one would find bugs and the API would change. However, this represents the first time that it’s made somewhat easy to have a play and experiment with the framework.

HISTORY OF AVALONIA

Many years ago, before WPF was the Windows Presentation Foundation and introduced XAML as the UI markup language for .NET, there was a project, which was codenamed ‘Avalon’. It was the codename of the WPF. Now, XAML is everywhere and the XAML Standard is a vocabulary specification.

Avalonia is an open source project, which clearly takes inspiration from Avalon and has an unapologetic love for XAML. Steven Kirk and a team of almost 50 contributors are asking what a cross-platform .NET UI framework look like. Avalonia, known formerly as Perspet is a multi-platform .NET UI framework. It’s important to note that while Avalonia may smell like WPF, it is not WPF however. It’s not cross-platform WPF, but it’s Avalonia. It does styles in a different manner than WPF and actually has plenty of subtle yet considerable syntax enhancements.

SOME MAJOR FEATURES IN THE RELEASE

1. Deferred Rendering. It renders to a low-level scenegraph on the UI thread, that’s then rendered to the window on a separate render thread. This greatly enhances the rendering performance, especially when animations are involved and also provides proper hit-testing of controls. Nevertheless, the old renderer is available still as the ImmediateRenderer class for those who want to render everything each frame.

2. Monomac-based Backend. A new Monomac-based backend for Mac OSX platforms. The new backed makes use of Cocoa window dialogs that make the application appear more native.

3. Relative Source Syntax Sugar. Introduced shorthand to bind to other controls relative to control being bound. In WPF, this is achieved through using the RelativeSource syntax on a binding.

4. Drawings. A convenient ways of creating vector icons, used by WPF. The Visual Studio Image Library gives a lot of icons as Drawings. Furthermore, there are other tools that could produce them. They’re more lightweight than Shape controls because they’re not part of the visual tree.

5. New Previewer with .NET Core support in Visual Studio extension. A new previewer architecture that should enable making designers for non-windows platforms. The new architecture uses a TCP transport protocol that communicates between the app and the designer in a platform-independent way. Still it has an option to embed the HWND that is used by the Visual Studio extension, but the default one would transfer rendered bit map data through TCP.

6. Added Control.Resources, StaticResource and DynamicResource. The new features are designed to follow WPF.UWP as closely as possible. Each control has its own Resources dictionary.

7. Calendar Control. Ported Silverlight Calendar control to Avalonia for all calendaring needs.

8. WPF integration. Added a seamless WPF integration. One could embed Avalonia controls in the WPF app with no need to crate native windows and with full layout integration that is allowed by the fact that the layout systems of WPF and Avalonia are almost the same.

Some other features

Other interesting features introduced in the release:

  • Buttons disabled when there’s a null in binding chain for Command
  • Upgrade ReactiveUI to the V8 alpha
  • Added FindAncestor binding mode
  • Tooltip: IsOpen, placement, offset
  • Switched to .NET Standard 2.0
  • Screen implementation
  • Added ShowTask bar icon implementation
  • Added orientation and IsIndeterminate properties to ProgressBar
  • Removed Cairo and GTK2 support
  • Add Vertical orientation option for PageSlide animations
  • Added AppBuilder methods for logging
  • Implemented three states on CheckBox, ToggleButton and RadioButton
  • PortableXAML

A whole range of dot net development services are available to cater to the various Asp.NET development requirements of businesses and other organizations wherever they may be in the world.

Top comments (0)