Scott Hanselman

What would a cross-platform .NET UI Framework look like? Exploring Avalonia

September 21, 2017 Comment on this post [28] Posted in Open Source | WPF
Sponsored By

Many years ago before WPF was the "Windows Presentation Foundation" and introduced XAML as a UI markup language for .NET, Windows, and more, there was a project codenamed "Avalon." Avalon was WPF's codename. XAML is everywhere now, and the XAML Standard is a vocabulary specification.

Avalonia is an open source project that clearly takes its inspiration from Avalon and has an unapologetic love for XAML. Steven Kirk (GitHubber by day) and a team of nearly 50 contributors are asking what would a cross-platform .NET UI Framework look like. WPF without the W, if you will.

Avalonia (formerly known as Perspex) is a multi-platform .NET UI framework. It can run on Windows, Linux, Mac OS X, iOS and Android.

YOU can try out the latest build of Avalonia available for download here: and probably get the "ControlCatalog.Desktop" zip file at the bottom. It includes a complete running sample app that will let you explore the available controls.

Avalonia is cross-platform XAML ZOMG

It's important note that while Avalonia may smell like WPF, it's not WPF. It's not cross-platform WPF - it's Avalonia. Make sense? Avalonia does styles differently than WPF, and actually has a lot of subtle but significant syntax improvements.

Avalonia is a multi-platform windowing toolkit - somewhat like WPF - that is intended to be multi- platform. It supports XAML, lookless controls and a flexible styling system, and runs on Windows using Direct2D and other operating systems using Gtk & Cairo.

It's in an alpha state but there's an active community excited about it and there's even a Visual Studio Extension (VSIX) to help you get File | New Project support and create an app fast. You can check out the source for the sample apps here

Just in the last few weeks you can see commits as they explore what a Linux-based .NET Core UI app would look like.

You can get an idea of what can be done with a framework like this by taking a look at how someone forked the MSBuildStructuredLog utility and ported it to Avalonia - making it cross-platform - in just hours. You can see a video of the port in action on Twitter. There is also a cross-platform REST client you can use to call your HTTP Web APIs at written with Avalonia.

The project is active but also short on documentation. I'm SURE that they'd love to hear from you on Twitter or in the issues on GitHub. Perhaps you could start contributing to open source and help Avalonia out!

What do you think?

Sponsor: Get the latest JetBrains Rider preview for .NET Core 2.0 support, Value Tracking and Call Tracking, MSTest runner, new code inspections and refactorings, and the Parallel Stacks view in debugger.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
September 21, 2017 10:00
This is AWESOME. The way to go for UIs. UWP isn't cross-platform by now, Avalonia IS. I really love the project. My personal congratulations to Steven Kirk (@grokys) and the guys. They're doing a very good work. Keep it up!
September 21, 2017 10:05
Some healthy competition for electron makes a lot of sense. Awesome thing!
September 21, 2017 10:19
With a little tweaking, and custom building, you can even use it on Linux on the Raspberry!!
September 21, 2017 12:04
When will Microsoft support Windows Forms/WPF in .NET Core as an official cross-platform solution?
September 21, 2017 12:40
@Hamed: I don't think that Windows Forms could (and probably should) be made a cross-platform solution. There is, well, too much Windows on it :-) The effort to port all these APIs and make it 100% compatible would not be worth it. WPF on the other side is probably more platform agnostic, but a HUGE project to migrate.
September 21, 2017 13:08
Given MS has got Xamarin and is pushing that for cross platform (iOS/Android/Windows) then why aren't MS doing this?

Ultimately using OSS is a huge risk to a company making a product unless that OSS is massive, like jQuery for example. If you have a product that's going to last years then you need tech that will do the same.

Separation of concerns will make it easier to replace your UI but it doesn't make it zero effort. If you have a large product then if the UI OSS goes under or drops out of favour for the next big thing of the week then you are kind of screwed. It's costly to replace your UI whilst having to simultaneously implement more work. MS should take on the mantle of something like this and improve Xamarin.
September 21, 2017 15:34
Hurry up and make UWP cross platform Microsoft :)
September 21, 2017 15:49
Don't know if others spotted it, but at .net conf this week Miguel announced that Xamarin.Forms would be usable from WPF. Not sure what that will look like yet as there don't seem to be any posts about it.

XAML standard will hopefully mean that most of the UI code can be shared and you can choose to use whichever 'runtime' you want like WPF, Avalonia etc. Think I've understood it anyway!
September 21, 2017 15:51
Neat. Have you ever looked into
September 21, 2017 18:47
This is cool, but doesn't xamarin.forms already do a lot of this? In 3.0 they are wanting to get it working on linux also.

I do like that XAML is being used as the basis for some other UI frameworks though that is awesome.
September 21, 2017 19:21
This seems pretty cool but what does it offer over Xamarin.Forms? Does it provide more controls? Just trying to understand what value it provides over XF.
September 21, 2017 19:44
@Hamend: The answer is never. That is the whole point of the project introduced in the article. Did you even read it?
September 21, 2017 21:23
Thanks for the writeup, Scott! There are some questions that people often ask, so to try and preempt these, I'll answer a few of them here:

Q: Why don't you follow the WPF/UWP/Silverlight API? I have stuff I'd like to port but you're making it difficult!

A: When I started writing Avalonia, it was intended to be an OSS port of WPF (you can see how far I got here but after a while I just wasn't enjoying it - I wanted to improve things. Since this was all being done on my free time, it came down to a choice between giving up or working on something I enjoyed: I chose the latter.

At this point I never really expected that anyone would actually want to use this thing I was writing so I didn't give much thought to keeping compatibility. Since people have started noticing Avalonia and even using it to create applications, that has changed somewhat. Now we're trying to follow existing XAML frameworks where it makes sense, and modernise or steal take inspiration from other frameworks where we think they've got some good ideas.

Q: Why don't you use native controls? Templated controls suck! They'll never look right on all platforms.

A: A very valid concern! If you want native controls take a look at @cwensley is doing amazing work there, and we're even using his Portable.Xaml as our XAML engine.
September 21, 2017 21:41
Oh yeah, also: yes our docs are terrible - please help! :)
September 21, 2017 23:20
This comment is the BEST EVER and is music to all XAML dens like myself lool:

"... Some folks really like desktop apps written in JavaScript, but the REST OF US are sane people :)"

Yeb, UI frameworks like these are for us sane people lool
September 21, 2017 23:21
sorry for the typos: Devs* not "dens".
September 22, 2017 1:05
This is a cool project and I'm glad the community is working on something like this.

That being said, this seems like the logical place for Microsoft to take Xamarin Forms (and make it an official upgrade path for WPF).

Though no one at Microsoft is willing to discuss this or even admit the need for an upgrade path for .NET Framework applications. All we hear from Microsoft is the absurd claim that .NET Framework and .NET Core will both continue to be developed concurrently ad infinitum , which is obviously nonsense.
September 22, 2017 10:23
This is great! Anything but UWP.
September 23, 2017 4:28
In my opinion, Avalonia is in desperate need of a community forum. The documentation is admittedly not in the best shape, and it's not even obvious that you can't do much development with it on linux. I tried to do a few things in the hope that if I just ignored the windows-only information, it would just work somehow - but it didn't :(.

One reason I didn't get anywhere is that I'm an experienced .NET developer who is running away from Windows as fast as I can. I have no chops at all on linux, so I'm still very lost. In short, I need help. If I could get some for Avalonia, I could potentially give a lot back to the project. My home machines are all linux now, and that's the way it's going to stay. It's develop on linux with netcore, or not at all.

I think the project is mainly unaware of the demand for a working solution to this problem. Most of the devs I know are toying with netcore on linux, and when a real solution becomes available, I believe we will see an explosion of .net apps on linux. But, we are only close. It's not there yet, and without a common place to share and discuss issues, anyone like me will be forced to remain on the sidelines.

Please, Avalonia, set up a forum. Heck, I'd donate a year of hosting if you do :). I believe the reward would be cementing Avalonia's place as the go to interface toolkit for netcore, destined to become as popular or more popular than WinForms or WPF.
September 23, 2017 16:23
It would be great to see a PoC, using Core for service and Avalonia for client.
September 24, 2017 4:09

The problem with Linux is that it doesn't have any real IDE for .NET anymore. MonoDevelop doesn't have proper .NET Core support and their distribution model with flatpak is completely broken. And that was the only IDE where we could potentially get our current XAML previewer working.

I'm planning to create a plugin for Rider, but it will require quite a bit of work.

Another issue is .NET Core SDK being unable to properly build projects targeting full .NET, anything that has net461 in TargetFramework(s) is broken. Same for goes for OSX, but VS4Mac at least has .NET Core debugging support.

But community forum is a good idea, we might figure out something about that. For now you can use StackOverflow with avaloniaui tag
September 26, 2017 2:24
I love the idea of having a cross-platform UI framework and I would love Microsoft to be the driving force behind a big effort like that. It's really the missing piece in the .NET Core story!
September 28, 2017 18:37
One more thing regarding Avalonia: instead of using markup, which I'd argue was inefficient with all those opening and closing brackets, can everything be done with C#?
September 28, 2017 18:39
...oh and could it reach out to WebAssembly?
September 28, 2017 19:36
Microsoft is actually going to add WPF, MacOS, Linux, and Tizen support for Xamarin.Forms 3.0. So your cross-platform .NET GUI framework is almost here.
September 29, 2017 12:53
To be honest, i don't like the UI style at all... especially the spacing control. look at the space between "Transition" dropdown and the picture. And the title "Carousel" spacing, makes me not comfortable.
October 03, 2017 16:37
@rod mac

Avalonia still has a way of defining styles, bindings and control templates from C# code. For example, that's how our default control theme had looked two years ago:

and that's how UI was defined:

WebAssembly is doable, but we need to wait for support from Mono or corert.
October 05, 2017 22:24
@Nikita Tsukanov

Thanks for the update. Avalonia sounds a compelling UI framework.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.