Avalonia
Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
Top Related Projects
WPF is a .NET Core UI framework for building Windows desktop applications.
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
A curated list of awesome Xamarin.Forms libraries and resources
Quick Overview
Avalonia is a cross-platform UI framework for .NET, providing a flexible and powerful toolkit for building desktop applications. It allows developers to create native-looking applications that run on Windows, macOS, Linux, iOS, Android, and WebAssembly using a single codebase.
Pros
- Cross-platform compatibility, supporting desktop, mobile, and web platforms
- Modern, XAML-based UI design with support for custom controls and styling
- Active community and regular updates
- Good performance and native-like look and feel on different platforms
Cons
- Smaller ecosystem compared to more established frameworks like WPF or Xamarin
- Learning curve for developers new to XAML-based UI development
- Limited third-party control libraries compared to other UI frameworks
- Documentation can be incomplete or outdated in some areas
Code Examples
- Creating a simple window with a button:
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
public class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
- Defining the UI layout using XAML:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Avalonia Example">
<StackPanel>
<TextBlock Text="Hello, Avalonia!" />
<Button Content="Click Me!" Click="Button_Click" />
</StackPanel>
</Window>
- Handling button click event:
public void Button_Click(object sender, RoutedEventArgs e)
{
var messageBox = MessageBoxManager.GetMessageBoxStandardWindow(
"Hello",
"You clicked the button!",
ButtonEnum.Ok);
messageBox.Show();
}
Getting Started
-
Install the Avalonia templates:
dotnet new -i Avalonia.Templates
-
Create a new Avalonia application:
dotnet new avalonia.app -o MyAvaloniaApp
-
Navigate to the project directory and run the application:
cd MyAvaloniaApp dotnet run
This will create and run a basic Avalonia application. You can then start modifying the XAML and C# files to build your UI and add functionality.
Competitor Comparisons
WPF is a .NET Core UI framework for building Windows desktop applications.
Pros of WPF
- Mature and well-established framework with extensive documentation and community support
- Rich set of built-in controls and layout options
- Seamless integration with other .NET technologies and Windows-specific features
Cons of WPF
- Limited to Windows platforms, lacking cross-platform support
- Steeper learning curve due to its complexity and XAML-based approach
- Slower development and update cycle compared to more modern frameworks
Code Comparison
WPF:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Click me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>
Avalonia:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Click me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>
The code comparison shows similarities in XAML structure between WPF and Avalonia, with minor differences in namespace declarations. Avalonia aims to provide a familiar experience for WPF developers while offering cross-platform capabilities.
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
Pros of Xamarin.Forms
- Mature ecosystem with extensive documentation and community support
- Native UI controls for each platform, ensuring a native look and feel
- Seamless integration with platform-specific APIs and features
Cons of Xamarin.Forms
- Limited to mobile and desktop platforms (iOS, Android, UWP)
- Performance can be slower compared to native development
- Steeper learning curve for developers new to mobile development
Code Comparison
Xamarin.Forms:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!" />
<Button Text="Click me" Clicked="OnButtonClicked" />
</StackLayout>
</ContentPage>
Avalonia:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBlock Text="Welcome to Avalonia!" />
<Button Content="Click me" Click="OnButtonClicked" />
</StackPanel>
</Window>
Both frameworks use XAML for UI definition, but Avalonia's syntax is more similar to WPF, while Xamarin.Forms has its own specific syntax. Avalonia offers a more flexible approach for cross-platform desktop development, while Xamarin.Forms is primarily focused on mobile platforms with some desktop support.
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
Pros of ReactiveUI
- Focuses on reactive programming paradigms, making it easier to handle complex UI interactions and data flows
- Provides a robust set of tools for managing application state and UI updates
- Offers cross-platform support for various .NET platforms, including Xamarin and WPF
Cons of ReactiveUI
- Steeper learning curve, especially for developers new to reactive programming concepts
- May introduce unnecessary complexity for simpler applications
- Requires additional setup and configuration compared to traditional MVVM frameworks
Code Comparison
ReactiveUI:
public class ViewModel : ReactiveObject
{
private string _searchTerm;
public string SearchTerm
{
get => _searchTerm;
set => this.RaiseAndSetIfChanged(ref _searchTerm, value);
}
}
Avalonia:
public class ViewModel : ViewModelBase
{
private string _searchTerm;
public string SearchTerm
{
get => _searchTerm;
set => SetProperty(ref _searchTerm, value);
}
}
While both frameworks support MVVM patterns, ReactiveUI emphasizes reactive programming techniques, whereas Avalonia focuses on providing a cross-platform UI framework with a more traditional approach to data binding and property changes.
A curated list of awesome Xamarin.Forms libraries and resources
Pros of awesome-xamarin-forms
- Extensive collection of resources, libraries, and tools for Xamarin.Forms development
- Community-driven and regularly updated with new content
- Covers a wide range of topics, including UI controls, testing, and deployment
Cons of awesome-xamarin-forms
- Not a framework itself, but a curated list of resources
- Lacks direct code implementation or functionality
- May include outdated or deprecated resources if not maintained frequently
Code Comparison
As awesome-xamarin-forms is a curated list and not a framework, a direct code comparison is not applicable. However, here's an example of how you might use a resource from the list in a Xamarin.Forms project:
// Using Xamarin.Forms
using Xamarin.Forms;
public class MainPage : ContentPage
{
public MainPage()
{
Content = new Label { Text = "Hello, Xamarin.Forms!" };
}
}
Avalonia, on the other hand, is a cross-platform UI framework. Here's a similar example in Avalonia:
// Using Avalonia
using Avalonia.Controls;
public class MainWindow : Window
{
public MainWindow()
{
Content = new TextBlock { Text = "Hello, Avalonia!" };
}
}
While awesome-xamarin-forms provides a wealth of resources for Xamarin.Forms development, Avalonia offers a different approach to cross-platform UI development with its own set of controls and paradigms.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ð About
Avalonia is a cross-platform UI framework for dotnet, providing a flexible styling system and supporting a wide range of platforms such as Windows, macOS, Linux, iOS, Android and WebAssembly. Avalonia is mature and production ready and is used by companies, including Schneider Electric, Unity, JetBrains and GitHub.
Considered by many to be the spiritual successor to WPF, Avalonia UI provides a familiar, modern development experience for XAML developers creating cross-platform applications. While Avalonia UI is similar to WPF, it isn't a 1:1 copy, and you'll find plenty of improvements.
For those seeking a cross-platform WPF, we have created Avalonia XPF, enabling WPF applications to run on macOS and Linux with little to no code changes. Avalonia XPF is a commercial product and is licensed per-app, per-platform.
Blog
To see the latest announcements and read about the state of Avalonia, check out the Avalonia UI Blog.
Breaking Changes
You can also see what breaking changes we have planned and what our past breaking changes have been.
Awesome Avalonia
Awesome Avalonia is community-curated list of awesome Avalonia UI tools, libraries, projects and resources. Go and see what people are building with Avalonia!
ð Getting Started
See our Get Started guide to begin developing apps with Avalonia UI.
Visual Studio
The Avalonia Visual Studio Extension contains project and control templates that will help you get started, or you can use the .NET Core CLI. For a starter guide see our documentation.
JetBrains Rider
JetBrains Rider now has official support for Avalonia.
Code completion, inspections and refactorings are supported out of the box, for XAML previewer add https://plugins.jetbrains.com/plugins/dev/14839
to plugin repositories and install AvaloniaRider plugin.
Avalonia Packages
Avalonia is delivered via NuGet package manager. You can find the packages here: https://www.nuget.org/packages/Avalonia/
Use these commands in the Package Manager console to install Avalonia manually:
Install-Package Avalonia
Install-Package Avalonia.Desktop
Showcase
See what others have built with Avalonia UI on our Showcase. We welcome submissions!
Bleeding Edge Builds
We also have a nightly build which tracks the current state of master. Although these packages are less stable than the release on NuGet.org, you'll get all the latest features and bugfixes right away and many of our users actually prefer this feed!
Learning
Documentation
Documentation can be found at https://docs.avaloniaui.net.
Tutorials
We also have a tutorial over there for newcomers.
Samples
We have a range of samples to help you get started.
Building and Using
See the build instructions here.
Contributing
This project exists thanks to all the people who contribute.
Please read the contribution guidelines before submitting a pull request.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the Code of Conduct.
Licence
Avalonia is licenced under the MIT licence.
Donate
Donating to the project is a fantastic way to thank our valued contributors for their hard work. Your donations are shared among our community and awarded for significant contributions.
If you need support see Commercial Support section below.
Donate with BTC or use Open Collective.
BTC: bc1q05wx78qemgy9x6ytl5ljk2xrt00yqargyjm8gx
Backers
Thank you to all our backers! ð [Become a backer]
Commercial Support
We have a range of support plans available for those looking to partner with the creators of Avalonia, enabling access to the best support at every step of the development process.
Please note that donations are not considered payment for commercial support agreements. Please contact us to discuss your needs first. team@avaloniaui.net
Avalonia XPF - Our cross-platform WPF
Unleash the full potential of your existing WPF apps with our cross-platform UI framework, enabling WPF apps to run on macOS and Linux without requiring expensive and risky rewrites.
Top Related Projects
WPF is a .NET Core UI framework for building Windows desktop applications.
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
A curated list of awesome Xamarin.Forms libraries and resources
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot