|
| 1 | +--- |
| 2 | +id: what-is-avalonia |
| 3 | +title: What is Avalonia? |
| 4 | +--- |
| 5 | + |
| 6 | +import AvaloniaArchitecture from '/img/overview/Architecture.png'; |
| 7 | +import MauiComparision from '/img/overview/MAUI-Comparision.png'; |
| 8 | + |
| 9 | +Avalonia is an open-source, cross-platform UI framework that enables developers to create application using .NET for Windows, macOS, Linux, iOS, Android and WebAssembly. |
| 10 | + |
| 11 | +It uses its own rendering engine to draw UI controls, ensuring consistent appearance and behavior across all supported platforms. This means that developers can share their UI code and maintain a uniform look and feel regardless of the target platform. |
| 12 | + |
| 13 | +<p><img className="image-zoom-medium" src={AvaloniaArchitecture} alt="" /></p> |
| 14 | + |
| 15 | + |
| 16 | +## Who Avalonia is for? |
| 17 | + |
| 18 | +Avalonia is for developers who want to: |
| 19 | + |
| 20 | +* Write cross-platform apps in XAML and C#, from a single shared code-base. |
| 21 | +* Share UI, layout and design across multiple platforms. |
| 22 | +* Share code, tests, and business logic across platforms. |
| 23 | + |
| 24 | + |
| 25 | +## How does Avalonia work? |
| 26 | +Avalonia unifies desktop, mobile, and web platforms through a unique approach that differs from traditional cross-platform frameworks. Rather than wrapping native UI controls, Avalonia implements its own cross-platform rendering engine that ensures pixel-perfect consistency across all supported platforms. |
| 27 | + |
| 28 | +### Architecture Overview |
| 29 | +Avalonia is built on .NET Standard 2.0, allowing it to run on any platform that supports .NET. The framework consists of several key layers: |
| 30 | + |
| 31 | +#### Core Platform-Agnostic Layer |
| 32 | +The majority of Avalonia's functionality resides in a platform-agnostic core layer that handles: |
| 33 | + |
| 34 | +* UI Controls and Layout |
| 35 | +* Visual Tree Management |
| 36 | +* Styling System |
| 37 | +* Data Binding |
| 38 | +* Input Handling |
| 39 | +* Animation Framework |
| 40 | + |
| 41 | +This core layer is completely platform-independent, meaning it behaves identically regardless of the operating system or device. |
| 42 | + |
| 43 | +#### Rendering Engine |
| 44 | +Unlike frameworks that rely on native UI controls, Avalonia uses its own rendering engine powered by either Skia or Direct2D. This approach means that: |
| 45 | + |
| 46 | +* Applications look and behave identically across platforms |
| 47 | +* Custom controls and visual effects can be implemented once and work everywhere |
| 48 | +* The framework isn't limited by platform-specific UI capabilities |
| 49 | + |
| 50 | +#### Platform Integration Layer |
| 51 | +Avalonia requires minimal platform-specific code to integrate with each supported platform. This layer handles: |
| 52 | + |
| 53 | +* Window Management |
| 54 | +* Input Events |
| 55 | +* Clipboard Operations |
| 56 | +* Native Dialogs |
| 57 | +* Hardware Acceleration |
| 58 | +* Platform-Specific Features |
| 59 | + |
| 60 | +#### Runtime Environment |
| 61 | +Avalonia applications run on the .NET runtime, whether that's .NET Core, or Mono. |
| 62 | + |
| 63 | +#### Comparison with Native Approaches |
| 64 | +While frameworks like .NET MAUI abstract over native UI controls, Avalonia takes a different approach: |
| 65 | + |
| 66 | +<p><img className="image-zoom-medium" src={MauiComparision} alt="" /></p> |
| 67 | + |
| 68 | +This architectural difference provides several benefits: |
| 69 | + |
| 70 | +* Consistent behavior across platforms |
| 71 | +* Pixel-perfect rendering |
| 72 | +* Full control over the UI stack |
| 73 | +* Simplified platform support |
| 74 | +* Reduced maintenance overhead |
| 75 | +* Better performance on resource-constrained devices |
| 76 | + |
| 77 | +### Integration with Native Platforms |
| 78 | + |
| 79 | +While Avalonia uses its own rendering engine, it still integrates seamlessly with native platform capabilities: |
| 80 | + |
| 81 | +* **Windows**: Supports Win32 APIs and modern Windows features |
| 82 | +* **Linux**: Works with X11, Wayland, and framebuffer rendering |
| 83 | +* **macOS**: Integrates with Cocoa and platform services |
| 84 | +* **Mobile**: Provides native lifecycle management and platform integration |
| 85 | +* **Web**: Runs via WebAssembly with full browser integration |
| 86 | + |
| 87 | +### Platform Support Requirements |
| 88 | +At its core, Avalonia requires just two fundamental capabilities to support a new platform: |
| 89 | + |
| 90 | +1. The ability to draw pixels on a screen |
| 91 | +2. The ability to receive input events |
| 92 | + |
| 93 | +This minimal requirement set is what allows Avalonia to support such a wide range of platforms, from desktop operating systems to embedded devices, and even unusual platforms like VNC servers. |
| 94 | + |
| 95 | +This architecture enables Avalonia to deliver on its promise of "One codebase, infinite possibilities" while maintaining high performance and native platform integration where it matters most. |
0 commit comments