Skills2026年5月6日·1 分钟阅读

Avalonia — Cross-Platform .NET UI Framework for Desktop, Mobile & Web

A cross-platform UI framework for .NET that lets you build apps for Windows, macOS, Linux, iOS, Android, and WebAssembly from a single C# and XAML codebase.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Avalonia UI
通用 CLI 安装命令
npx tokrepo install 777c4ff9-4946-11f1-9bc6-00163e2b0d79

Introduction

Avalonia is an open-source UI framework that brings WPF-style XAML development to every major platform. It provides a retained-mode rendering pipeline with its own layout and styling engine, so apps look and behave consistently whether they run on Windows, macOS, Linux, iOS, Android, or in the browser via WebAssembly.

What Avalonia Does

  • Renders pixel-identical UI across Windows, macOS, Linux, iOS, Android, and WASM
  • Uses a XAML dialect with data binding, styles, control templates, and resource dictionaries
  • Provides an MVVM-first architecture with built-in ReactiveUI and CommunityToolkit support
  • Ships a DevTools inspector for live visual tree and property debugging
  • Offers a Skia-based or Composition-based rendering backend for GPU-accelerated drawing

Architecture Overview

Avalonia's rendering pipeline sits on top of platform-specific backends (Win32, X11, Cocoa, Android, iOS, browser canvas). The layout engine processes a visual tree of controls, each with measure and arrange passes similar to WPF. Styles are resolved via a CSS-like selector system that cascades through the tree. The Composition renderer batches draw calls and sends them to Skia or Direct2D for GPU execution. Input is abstracted through platform dispatchers that feed pointer, keyboard, and touch events into the routed event system.

Self-Hosting & Configuration

  • Install .NET 8+ SDK and the Avalonia.Templates NuGet package to scaffold projects
  • Choose a project template: avalonia.mvvm, avalonia.app, or avalonia.xplat for mobile targets
  • Configure App.axaml for global styles, themes (Fluent or Simple), and resource dictionaries
  • Add platform heads (iOS, Android, Browser) by including the corresponding target framework in the csproj
  • Use dotnet publish with runtime identifiers (win-x64, osx-arm64, linux-x64) for platform builds

Key Features

  • True cross-platform: desktop, mobile, embedded, and WebAssembly from one codebase
  • Familiar XAML and C# development model for WPF and UWP developers
  • Hot Reload for XAML changes during debugging
  • Fluent and Simple built-in themes with full CSS-like style override support
  • Extensive control library including DataGrid, TreeView, and third-party ecosystem

Comparison with Similar Tools

  • .NET MAUI — Microsoft's official cross-platform framework using native controls; Avalonia uses its own rendering for pixel-perfect consistency
  • Uno Platform — renders via native controls or Skia; Avalonia is Skia-first with a WPF-closer API
  • Electron — web-tech desktop apps with higher memory footprint; Avalonia is native .NET
  • Flutter — Dart-based with its own engine; Avalonia targets .NET developers with XAML
  • wxWidgets — C++ native-widget toolkit; Avalonia is managed code with MVVM patterns

FAQ

Q: Can I use Avalonia if I know WPF? A: Yes. The XAML dialect, data binding, and control model are intentionally close to WPF, though some APIs differ.

Q: Does Avalonia support AOT compilation? A: Yes. Avalonia works with .NET Native AOT for reduced startup time and smaller binaries on supported platforms.

Q: How mature is mobile support? A: iOS and Android support reached stable status in Avalonia 11. Production apps ship on both platforms.

Q: Is there a visual designer? A: The Avalonia extension for JetBrains Rider includes a live XAML previewer. VS Code and Visual Studio extensions also provide previews.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产