Avalonia UI is a cross-platform UI framework available for Dotnet Core. It is a project part of the .Net Foundation. Its main appeal is to provide the ability to create desktop applications for Windows, Linux and MacOS with a single code base.
In this tutorial we will see how to install the Avalonia templates and create a blank application.
The first thing we need to do is installing the Avalonia Templates so the dotnet new command could use them when creating new applications.
You need to go to the following Github Repository Avalonia Templates for dotnet new and download the zip version. Alternatively, you could clone it to your machine if you have git installed.
After you have unzipped the file in the location you prefer. It is needed to run the following command. Keep in mind the path you need to use is the route to the unzipped templates
dotnet new --install [path-to-templates-folder]
Tip: An easy way to add the folder path to the command line is to drag and drop the folder from the File Explorer
The command executed on the previous step adds a few more templates to the
dotnet new command.
There are two project templates added are the following:
- avalonia.app: To create a barebones Avalonia application
- avalonia.mvvm: To create an application that uses the Model-View-ViewModel pattern with ReactiveUI
To create a new application you need to run the following command:
dotnet new avalonia.app -o MyApp
MyApp is the name of the application we are creating.
To run the application you need to get into the MyApp folder
and then run the app with the dotnet CLI
The result will be the following as a blank app shows on screen.
I hope you find this useful. In following entries we will continue exploring the Avalonia UI framework.