Skip to main content

Samples and tutorials

Explore tutorials, sample apps, and quick guides to accelerate your Avalonia learning.

Tutorials

Starter Tutorial

Build your first Avalonia app step by step, from controls and layout to events and data conversion.

ToDo List App

Build a to-do list app using the MVVM pattern with bindings, commands, styling, and basic I/O.

Music Store App

Build a graphical Music Store app with dialogs, images, collections, and data persistence.

MVVM samples

Basic MVVM

Use the MVVM pattern to receive and process text input by the user.

Binding and converters

Convert a date to a string value, and thereby calculate the age of a person.

Value converter

Incorporate a converter inside your binding to calculate a new value for the View.

Commands

How to invoke methods in your ViewModel from your user interface using commands.

Data validation

Validate properties and display an error message if the values are invalid.

Dialog manager

Create a dialog manager service that helps you show dialogs in your app.

Data templates samples

Basic DataTemplate

Use DataTemplates to control how your data is displayed.

FuncDataTemplate

Create an advanced DataTemplate in code with a FuncDataTemplate.

IDataTemplate

Implement IDataTemplate in your own class to have full control over your DataTemplates.

Styles and drawing samples

Button customization

Customize the style of a button by creating reusable styles.

Making lists

Create lists of data using bindings and the ListBox control.

Native menus

Use native menus in your Avalonia app on macOS and Linux.

Splash screen

Build a custom splash screen that loads before your MainWindow.

Rect painter

Create a custom rendered control that interacts with the mouse to form a simple paint application.

Loading images

See how to load images via XAML, bindings and from the internet.

Using fonts

Use custom fonts, such as Google fonts, within your application.

Battle City

A sample 2D game in Avalonia created without writing any rendering code.

Custom controls samples

Rating control

Create a rating control for users to vote by clicking one of several stars.

Snowflake control

Create a custom control that overrides OnRender to use more advanced rendering instead.

Testing samples

Headless testing with XUnit

Test your app without a visible graphic user interface using Avalonia's headless platform with XUnit.

Headless testing with NUnit

Test your app without a visible graphic user interface using Avalonia's headless platform with NUnit.

Testing with Appium

Automated tests for UI interactions, such as button clicks, text input, and screen navigation.

Other samples

Clipboard operations

Interact with the device's clipboard to copy and paste text.

Drag-and-drop operations

Implement dragging and dropping in an Avalonia app.

Native file operations

Using native 'Save as' and 'Open file' dialogs.

IoC file operations

Using native 'Save as' and 'Open file' dialogs with inversion of control (IoC).

Localization

An example of how to localize an Avalonia app.

Basic view locator

Change the contents of your UI using a view locator.

Native AOT

Set up your app to build with native ahead-of-time (AOT).

See also