Skip to main content
Version: 11.0.x

Samples

Model-View-ViewModel (MVVM)

Basic MVVM

This sample will show you how you can use the MVVM-pattern to receive and process text input by the user.

XAMLC#MVVM

Binding & Converters

This sample will show you how you can use use bindings and converters to convert a Date to a string value (calculating the age of a person).

XAMLC#MVVMConverter

Commands

This sample will show you how you can use Commands to invoke methods in your ViewModel from your user interface.

XAMLC#MVVM

ValueConverter

In this sample you will learn how you can use a Converter inside your Binding in order to calculate a new value for the View.

XAMLC#MVVMConverter

Data Validation

This sample you will learn how to validate properties and display an error message to the user, if the entered values are invalid.

XAMLC#MVVM

Dialogs

This sample will show you how to use Reactive UI Interactions to show [dialogs] in your MVVM application

XAMLC#MVVMRxUI

Dialog Manager

This sample will show you how to write a service (we will call it dialog manager) that will help you to show dialogs in your MVVM application

XAMLC#MVVM

DataTemplates

Basic DataTemplate

This sample will show you how you can use DataTemplates to control how your data is displayed.

XAMLC#DataTemplate

FuncDataTemplate

This sample will show you how to use a FuncDataTemplate to create an advanced DataTemplate in code.

XAMLC#DataTemplate

IDataTemplate

This sample will show you how to implement IDataTemplate in your own class to have full control over your DataTemplates.

XAMLC#DataTemplate

Controls, Styles & Drawing

Customized Button

This sample will show you how to customize the style of a button by creating reusable styles.

XAMLC#Style

Making Lists

This sample will show you how to create lists of data using Bindings and a ListBox control

XAMLC#Lists

Native Menus

This sample will show you how to use native menus on macOS and Linux.

XAMLC#Menus

Splash Screen

This sample will show you how to create a custom Splash Screen that loads before your MainWindow

XAMLC#Splash

Rect Painter

This sample will show you how to create a custom rendered control which interacts with the mouse, to form a simple paint application.

XAMLC#Drawing

Image Loading

This sample will show you how to load images via XAML, Bindings and from the internet.

XAMLC#Images

Using Google Fonts

This sample will show you how to use Google fonts within your application

XAMLC#Font

BattleCity

The purpose of the sample is to demonstrate that how to create a 2D game in Avalonia without writing any rendering code.

XAMLC#Drawing

Custom Controls

Custom Rating Control

This sample will show you how to create a custom control. The goal is to create a rating control, where the user can vote via clicking one of several stars.

XAMLC#Custom Controls

Custom Snowflakes Control

This sample will show you how to create a custom control that overrides OnRender in order to have advanced render capabilities.

XAMLC#Custom Controls

Miscellaneous

Clipboard Operations

This sample demonstrates how to interat with the devices clipboard and copy and paste text.

XAMLC#Clipboard

Drag and Drop Operations

This sample demonstrates how to implement dragging and dropping within your Avalonia application.

XAMLC#Drag-and-Drop

Native File Dialogs

This sample demonstrates how to use the native Save As and Open File dialogs.

XAMLC#Dialogs

Basic Localization

This sample demonstrates how to localize your Avalonia application.

XAMLC#Localization

Basic Inversion of Control

This sample demonstrates how to use the native Save As and Open File dialogs with IoC.

XAMLC#DialogsIoC

Basic ViewLocator

This sample will show you how to use a ViewLocator in order to change the contents of your UI.

XAMLC#Navigation

Native AOT

This sample will show you how to setup your application for building with Native AOT

XAMLC#Native AOT

Automated UI Testing

Headless Testing with XUnit

This sample will show you how the headless platform in Avalonia provides the capability to run Avalonia applications without a visible graphical user interface

XAMLC#TestingXUnit

Headless Testing with NUnit

This sample will show you how the headless platform in Avalonia provides the capability to run Avalonia applications without a visible graphical user interface

XAMLC#TestingNUnit

Testing with Appium

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

XAMLC#TestingAppium