English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

From WinUI to Cross-Platform: A Deep Dive into Uno Platform's Architecture and Design Philosophy

Forum topic · QianXun · 2026-02-18

Summary

This article analyzes how Uno Platform enables a single WinUI 3 codebase to run on Windows, iOS, Android, WebAssembly, macOS, and Linux. Unlike Xamarin.Forms/.NET MAUI, which builds a lowest-common-denominator abstraction layer, Uno fully replicates the WinUI 3 API surface, letting existing Windows UI skills and code transfer directly. The post first reviews WinUI 3's layered architecture—the framework layer (controls, data binding, dependency properties), the retained-mode Visual/Composition layer, and the DirectX graphics layer—and explains the dependency property value precedence system. It then details Uno's key engineering decisions: a dual rendering strategy (Skia-based pixel-consistent rendering as the default, versus native control mapping as a legacy mode); converting DependencyObject from a base class into an IDependencyObject interface implemented via C# source generators to solve single-inheritance conflicts with UIView/ViewGroup; compiling XAML into C# code with Roslyn source generators instead of XBF; and the bait-and-switch package strategy that uses real WinUI 3 on Windows and Uno's reimplementation elsewhere. It also covers platform heads project structure, file-suffix and XAML namespace techniques for platform-specific code, and the MVUX (Model-View-Update-eXtended) reactive pattern with immutable models, IFeed/IState abstractions, and FeedView for asynchronous UI states.

From WinUI to Cross-Platform: A Deep Dive into Uno Platform's Architecture and Design Philosophy

*Structured summary of a Chinese forum post analyzing Uno Platform's architecture.*

Key points

  • In the .NET ecosystem, cross-platform UI frameworks take different approaches: Xamarin.Forms / .NET MAUI use an abstraction layer, Avalonia self-renders, and Uno Platform fully replicates the WinUI 3 API, allowing one WinUI codebase to target Windows, iOS, Android, WebAssembly, macOS, and Linux.
  • Understanding WinUI 3

  • Three generations of Windows UI tech: WPF (2006, managed, DirectX 9, Windows-only), UWP XAML (2015, native C++ core, XAML engine baked into the OS), and WinUI 3 (2020, decoupled from the OS release cycle via Windows App SDK, DirectX 12).
  • WinUI 3's layered architecture:
  • Application layer: XAML + C#/C++ business code
  • Framework layer: Microsoft.UI.Xaml.* (controls, data binding, dependency property system, Visual State Manager)
  • Visual layer: Microsoft.UI.Composition (Compositor, visual tree, effects, animation) — a retained-mode API
  • Graphics layer: DirectX / DirectComposition with GPU acceleration
  • Dependency properties are the soul of XAML, with value precedence from high to low: animated value → local value → templated value → style setter → default value, enabling styles, templates, binding, and animation to cooperate.
  • Uno Platform's cross-platform strategy

  • API compatibility rather than abstraction: instead of designing a minimal common-denominator API like Xamarin.Forms, Uno adopts Microsoft's WinUI 3 API design directly, so developer skills and code migrate as-is.
  • Dual rendering architecture:
  • *Skia rendering (default)*: the C# Uno.UI framework layer draws via Google's Skia 2D engine on Metal/OpenGL/WebGL backends — pixel-identical output on every platform and full Composition API support.
  • *Native rendering (legacy)*: UIElement maps to UIView on iOS, ViewGroup on Android, and DOM elements on WebAssembly, giving native control behavior, accessibility, and embeddability.
  • DependencyObject as an interface: since C# lacks multiple inheritance, a Button cannot inherit both DependencyObject and UIView/ViewGroup. Uno turns DependencyObject into an IDependencyObject interface, and C# source generators (e.g., [GeneratedDependencyProperty]) emit the GetValue/SetValue implementations at compile time.
  • XAML compilation via source generators: rather than WinUI's .xbf binary format, Uno's Roslyn-based XamlFileGenerator compiles XAML into C# code (InitializeComponent, x:Name fields, compiled x:Bind), giving compile-time type checking, better runtime performance, and debuggable generated code.
  • Platform adaptation

  • Platform heads: a single shared project contains platform entry points under Platforms/Android, Platforms/iOS, Platforms/WebAssembly, and Platforms/Desktop.
  • Bait-and-switch: at compile time, code references a type-only Uno.WinUI facade; at publish time, the real implementation is swapped in — genuine WinUI 3 (Windows App SDK) on Windows, and Uno's reimplementations (Uno.WinUI.iOS, Uno.WinUI.Android, Uno.WinUI.WebAssembly, Uno.WinUI.Skia) elsewhere.
  • Platform-specific code is written via file-suffix conventions (FilePicker.Android.cs, FilePicker.iOS.cs, FilePicker.Skia.cs) or XAML namespaces like http://uno.ui/android and http://uno.ui/ios for embedding native views.
  • Design patterns: MVUX and FeedView

  • MVUX (Model-View-Update-eXtended) adapts Elmish/Redux ideas to XAML: immutable record models, a single-direction data flow (View sends intents to the Model), and source-generated bindable proxies. Key abstractions:
  • IFeed<T> — asynchronous data streams that automatically update the UI
  • IState<T> — user-input state supporting two-way binding
  • FeedView elegantly handles loading / error / success states of async operations, replacing hand-managed VisualStates.

Takeaway

Uno Platform shows that cross-platform UI can be achieved by faithful API reimplementation plus compile-time code generation rather than by inventing a new abstraction — preserving the WinUI ecosystem while reaching every major platform.

Tags

#uno-platform#winui3#dotnet#cross-platform#xaml#skia#source-generators#mvux

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/176922811