xaml-csharp-development-skill-for-avalonia

Avalonia App-Building API Map

This map focuses on public APIs that matter directly when building applications (not internal rendering/runtime internals).

1) App Startup and Lifetime

AppBuilder (src/Avalonia.Controls/AppBuilder.cs)

Primary composition root:

Use:

Avoid:

Application (src/Avalonia.Controls/Application.cs)

Core extension points:

Global state and resources:

Use:

Lifetime interfaces (src/Avalonia.Controls/ApplicationLifetimes/*.cs)

Desktop helpers:

Use:

2) XAML Loading and Binding

XAML loader APIs

AvaloniaXamlLoader (src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs):

AvaloniaRuntimeXamlLoader (src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaRuntimeXamlLoader.cs):

Use:

AOT/trimming notes:

Binding API families

Compiled path (preferred):

Reflection path (fallback):

Core binding controls:

Converter APIs:

Compiled path builder capabilities:

Use:

3) Property System and Reactive Data Flow

Property registration and value APIs

AvaloniaProperty / AvaloniaProperty<T>:

AvaloniaObject:

Use:

Observables and bindings

AvaloniaObjectExtensions:

Use:

4) UI Thread and Scheduling

Dispatcher (src/Avalonia.Base/Threading):

Use:

5) Controls, Templates, and DataTemplates

Core view types:

Window highlights:

TopLevel highlights:

Template/data template APIs:

Menu surface APIs:

Tray and notification APIs:

Scrolling, text editing, and gesture APIs:

Automation and attached behavior APIs:

Important behavior:

6) Styling, Themes, and Resources

Key APIs:

XAML include APIs:

Media primitives:

Use:

7) Input, Commands, and Routed Events

Input/command APIs:

Routed event APIs:

Use:

8) Platform Bootstrapping APIs

Desktop and shared:

Platform-specific entry points:

Advanced graphics/interop surfaces (specialized):

Use:

9) Build and Tooling Surface

MSBuild properties (package/build files):

Item groups:

Source generator knobs (Avalonia.Generators.props):

Use:

10) High-Value Best-Practice Decisions

XAML-First and Code-Only Usage

Default guidance for this skill:

XAML-first references:

XAML-first usage example:

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:MyApp.ViewModels"
             xmlns:views="using:MyApp.Views"
             x:Class="MyApp.App">
  <Application.Styles>
    <FluentTheme />
  </Application.Styles>

  <Application.DataTemplates>
    <DataTemplate x:DataType="vm:MainViewModel">
      <views:MainView />
    </DataTemplate>
  </Application.DataTemplates>
</Application>

Code-only usage example (on request):

using Avalonia;
using Avalonia.Controls;
using Avalonia.Themes.Fluent;

public static class CodeOnlyBootstrap
{
    public static void ConfigureApp(Application app)
    {
        app.Styles.Add(new FluentTheme());

        var window = new Window
        {
            Width = 640,
            Height = 360,
            DataContext = new MainWindowViewModel(),
            Content = new TextBlock
            {
                Margin = new Thickness(16),
                Text = "Hello Avalonia"
            }
        };

        window.Show();
    }
}