Cross-platform GUIs with open source .NET using Eto.Forms
This is one of those "Did you know you could do THAT?" Many folks have figured out that C#/F#/.NET is cross-platform and open0source and runs on basically any operating system. People are using it to create micro services, web sites, and webAPI's all over. Not to mention iPhone/Android apps with Xamarin and video games with Unity and MonoGame.
But what about cross platform UIs?
While not officially supported by Microsoft - you can do some awesome stuff...as is how Open Source is supposed to work! Remember that there's a family of .NET Runtimes now, there's the .NET Framework on Windows, there's xplat .NET Core, and there's xplat Mono.
Eto.Forms has been in development since 2012 and is a cross-platform framework for creating GUI (Graphical User Interface, natch) applications with .NET that run across multiple platforms using their native toolkit. Not like Java in the 90s with custom painted buttons on canvas.
It's being used for real stuff! In fact, PabloDraw is an Ansi/Ascii text editor that you didn't know you needed in your life. But you do. It runs on Windows, Mac, and Linux and was written using Eto.Forms but has a native UI on each platform. Be sure to check out Curtis Wensley's Twitter account for some cool examples of what PabloDraw and Eto.Forms can do!
- OS X: MonoMac or Xamarin.Mac (and also iOS via Xamarin)
- Linux: GTK# 2 or 3
- Windows: Windows Forms (using GDI or Direct2D) or WPF
Here's an example Hello World. Note that it's not just Code First, you can also use Xaml, or even Json (.jeto) to layout your forms!
using Eto.Forms; using Eto.Drawing; public class MyForm : Form { public MyForm () { Title = "My Cross-Platform App" ; ClientSize = new Size(200, 200); Content = new Label { Text = "Hello World!" }; } [STAThread] static void Main() { new Application().Run( new MyForm()); } } |
Or I can just File | New Project with their Visual Studio Extension. You should definitely give it a try.
Even on the same platform (Windows in the below example) amazingly Eto.Forms can use whatever Native Controls you prefer. Here's a great example zip that has precompiled test apps.
Once you've installed a new version of Mono on Ubuntu, you can run the same sample as Gtk3, as I'm doing here in a VM. AMAZING.
Here's some example applications that are in the wild, using Eto.Forms:
- MonoGame Pipeline Tool - Content manager for MonoGame
- Manager - Accounting Software
- PabloDraw - Character based drawing application
- JabbR.Desktop - JabbR client
- Notedown - Note taking application
- Eto.Test - Application to test the functionality of each widget
- DotImaging.UI - Portable UI elements for DotImaging
There's so much cool stuff happening in open source .NET right now, and Eto.Forms is actively looking for help. Go check out their excellent Wiki, read the Tutorials, and maybe get involved!
Sponsor: Get the latest JetBrains Rider for debugging third-party .NET code, Smart Step Into, more debugger improvements, C# Interactive, new project wizard, and formatting code in columns.
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.



About Newsletter
Pushing Eto.Forms further, I have use Eto.Forms with OpenTK to create a C# 3D game map editor: https://github.com/bchavez/SharpFlame
SharpFlame works on Linux and Windows, but not MacOS yet (due to a bug in OpenTK not Eto.Forms). It's really great to see .NET getting very close to building 3D cross-platform apps too. :)
BTW, the Wiki link to Eto.Forms at the bottom of the post is broken. Regardless, EXCELLENT post!
I highly appreciate the work done in Avalonia (WPF syle) and Eto.Forms (Forms sytle). I've used both for private projects with success.
But to make .Net Core relevant in the corporate world, there needs to be a UI framework officially supported my MSFT, with a guaranteed support window. We have have maintenance windows of at least 5 years, and no manager will agree to use such frameworks. If the maintainers move to the next thing, MSFT overhauls half of it's APIs gain, etc, there is a severe risk the framework is left for dead while the community moves to the next thing.
The constant changes of direction in .Net core already damaged it's reputation, and promoting community/hobbyist projects as a replacement for a proper UI framework with reliable support does not help.
These days it looks like .NET 4.x is going the same way as Silverlight. Where SL was and is still something great, it s even super secure and x platform. Microsoft does not seem to realise this. Development with .NET today seems only interesting for .NET Core but be aware of the dangers which are very real:
See https://www.preemptive.com/blog for more info on protecting.
Focus in Microsoft is on Azure. Thats why they created Visual Studio Code and added easy access Azure templates. Which is great. Azure is a nice peace of work. You have to realise that most MS efforts are focused on this. Which is all Ok.
Will I work in .NET Core? Well yes of course when it is a suitable choice. For example a complex multiple tenancy or a local intra web Application on which I can control the updates. If you build just web sites choose WordPress (with auto updates) or for small services use NodeJs. It all works on Azure too. For mobile find something else. Really.
In the end, it all boils down to dependencies and control. What do you as a developer control?
Be Safe.
Comments are closed.
https://github.com/praeclarum/Ooui
Works in both native and web scenarios, 100% code and view reuse. .NET is officially relevant again.