Nick Polyak - Thoughts on Avalonia

Interview with Nick Polyak.

...
Dan Walmsley

Nick Polyak is a software architect, developer, and educator.

He has written many award-winning articles on CodeProject about programming, software architecture, design patterns, and more recently many articles about Avalonia.

Nick wrote one of the first MVVM pattern tutorials that I used when learning to work with WPF many years ago.

I caught up with Nick to get his thoughts on Avalonia.

When did you first discover Avalonia and what have you used it for since then?

My path to Avalonia developed over many years. When WPF was released I immediately fell in love with the groundbreaking new framework. This was because WPF brought many new concepts that are very powerful for UI development for example:

  • Visual and Logical Trees
  • Attached or Dependency Properties
  • Attached Routed Events
  • Bindings and the Related MVVM pattern
  • ControlTemplates
  • DataTemplates
  • Styles
  • Behaviors

Once Silverlight came along it opened up some new possibilities. It had almost all the features of WPF and could run in the browser, Windows, Linux, Mac.

Unfortunately, Microsoft abandoned Silverlight and that was the end of my cross-platform WPF ambitions.

What came next, frameworks like UWP and Xamarin always compromised the power of WPF, important features were left out, and even considering the web frameworks nothing came close to WPF.

Since then, I continued using WPF on Windows, at the same time looking for other frameworks both within the Microsoft universe and from the Open Source community.

About 4 years ago, I stumbled across Avalonia. I was not sure initially about the maturity of the framework (4 years ago it was in a much different place to today) so I kept an eye on the project and waited for it to develop.

Recently, I began to work on a contract with a hedge fund company. They needed a desktop UI application running both on Windows and Linux. I tried Avalonia again and became convinced that the framework was quite mature for both platforms.

Avalonia is the first framework I have discovered that not only matches WPFs concepts and APIs but in many respects exceeds them. They even fixed some of the bugs and problems that WPF had!

What are the advantages Avalonia UI has?

Avalonia provides you with the best powers of UI development combined with ease of usage. Additionally, Avalonia is truly multiplatform and your apps will run on Windows, Linux, and Mac with it.

Recently, Avalonia also released a Blazor-based WebAssembly version which allows running Avalonia apps on major browsers at any platform they support.

I'm told that mobile support is coming very soon also.

In the introduction section of my article Multiplatform UI Coding with AvaloniaUI in Easy Samples. Part 1 - AvaloniaUI Building Blocks I explain why I believe that Avalonia is better, more powerful, and easier to program than other frameworks including UWP, Xamarin, or Web-based technologies.

In addition to implementing all the WPF concepts mentioned above, Avalonia also utilizes some concepts that had not yet been discovered by the time WPF was created, for example, concepts coming from Reactive Extensions. As a result, their bindings and routed events are more powerful and less buggy than those of WPF.

In short, Avalonia is a multiplatform WPF++ that also runs in all major browsers.

Just like WPF (and unlike Web and Xamarin programming) Avalonia is very flexible and compositional. An experienced WPF or Avalonia software engineer can compose any control to consist of any primitives he wants, e.g. a Button or ComboBox (dropdown) can be composed of multiple images, borders, shapes, or text. The Avalonia visual tree is built with real primitives, like Borders, Images, Shapes, or TextBlocks. By contrast, in Xamarin and Web programming the visual tree (or HTML DOM) ends with much coarser (more complex) items like basic controls including buttons or dropdowns themselves. Correspondingly control customization is much easier and more powerful in Avalonia.

Now that Microsoft has open-sourced .NET, Avalonia is the missing piece that enables multiplatform .NET UI development a reality.

As someone who helps educate about software development, why should people learn to use Avalonia, and do you think it is easy to pick up?

For people with expertise in WPF, Silverlight, or UWP adapting to Avalonia is a breeze. In particular, after working with Avalonia for two weeks I figured out the most important differences between Avalonia and WPF and became capable of developing in Avalonia as fast as in WPF.

For people with no previous experience with any of the above frameworks, there will be a learning curve, which I believe they will have to go through anyways if they want to learn best practices and important concepts applicable to any UI development.

Those who worked with Xamarin previously will find many familiar concepts only implemented in a more powerful and flexible way with the added benefit of being easier to use.

For people with experience in Angular, the bindings, data templates, and MVVM concepts should be familiar, while those who know React, should be somewhat familiar with the concept of lookless controls and the hierarchical composition of controls and views.

How has the response been to your articles? I noticed you won the "Top C# article" award many times on CodeProject?

The response to my articles has been very positive. Based on CodeProject statistics, my articles were read by tens of thousands of people, and most of those who vote for the articles - give me the highest grade.

Many of my articles were voted to be the best of the month.

Due to the success of my Avalonia articles I have been selected as one of CodeProject's MVAs (Most Valued Authors) for 2022.

Based on the above, I do think that Avalonia has a great future ahead, it's getting popular by the day and will continue to grow.

What do you think the future will bring for Avalonia?

Even at present, there is no other multiplatform framework for building desktop applications that can come even close to Avalonia.

I believe that Avalonia has great potential and the key to unlocking this potential is better public relations (social media and marketing), continuing to improve the documentation, and fixing some well-known issues.

Also, I think it is very important to further stabilize the browser version and to allow mobile development in Avalonia both for Android and iOS, starting perhaps with Android.

Where should people go to find your articles, projects, code?

Since starting to work with Avalonia, I have built an open-source multiplatform docking framework for Avalonia called UniDock; it supports tabbing and stacking multiple windows. It is quite mature now and has been used in several projects already and (from my point of view) has more features and better functionality than WPF-based frameworks like AvalonDock, or comparable WPF Docking controls from professional control vendors. The main article detailing the UniDock functionality is UniDock - A New Multiplatform UI Docking Framework. UniDock Power Features.

Image UniDock

I also built and released open-source tools for theming and localizing Avalonia applications. See my article: Theming and Localization Functionality for Multiplatform Avalonia UI Framework for more information.

There are several tutorials that I have published intending to teach Avalonia to beginners and demonstrate the beauty of building with Avalonia and related concepts.

Here are the links to those articles in the same order in which they should be read:

  1. Multiplatform UI Coding with AvaloniaUI in Easy Samples. Part 1 - AvaloniaUI Building Blocks

  2. Basics of XAML in Easy Samples for Multiplatform Avalonia .NET Framework

  3. Multiplatform Avalonia .NET Framework Programming Basic Concepts in Easy Samples

  4. Multiplatform Avalonia .NET Framework Programming Advanced Concepts in Easy Samples

  5. Behavior Pattern - Visual Behaviors in WPF and Avalonia with Practical Samples

Additionally, I have published on Github NP.Avalonia.Visuals an open-source package containing some important behaviors, utilities, and controls, with accompanying article. It provides the following controls:

CustomWindow
AutoGrid
LabeledControl
More functionality, including some very useful utilities and behaviors, will be presented in future articles.

Latest Posts

Here’s what you might have missed.