avalonia
Installation
SKILL.md
Avalonia UI (v12)
Verified against Avalonia 12.1.x. Avalonia 12 requires .NET 8+ (.NET 10 recommended) and makes compiled bindings the default. Pair this skill with desktop-mvvm for view-model patterns.
Core Principles
- Compiled bindings everywhere — In Avalonia 12,
{Binding}in XAML compiles by default (AvaloniaUseCompiledBindingsByDefault=true). Every view andDataTemplateneedsx:DataType. Binding typos become build errors instead of silent blank fields, and there's no reflection, so trimming and AOT keep working. - Views are mapped to view models at compile time — Use typed
DataTemplates, or a dictionary-basedViewLocator. The template's reflectionViewLocator(Type.GetType+Activator.CreateInstance) breaks under trimming. UserControlfor composition,TemplatedControlfor reusable controls — A lookless templated control can be restyled by consumers. AUserControlis just a reusable chunk of a screen.- Platform services come from
TopLevel— UseTopLevel.GetTopLevel(visual)to get the file picker (StorageProvider),Clipboard, andLauncher. These work on Windows, macOS, Linux, and browser. Never reach for Win32/WinForms dialogs. - Build and test on every target OS — Fonts, DPI, window chrome, and file paths differ by platform. A CI matrix (windows/macos/ubuntu) catches problems before users do.