FerroUI: Avalonia, ported
A whole C# toolkit, its XAML and its themes, carried into Rust.
FerroUI takes an approach no other framework in this book takes. It is a port of Avalonia, the cross-platform C# toolkit modelled on WPF, that keeps Avalonia's architecture, contracts and behaviour so that its apps, themes and XAML carry over. It first appeared on crates.io on 15 October 2026, and ten releases later it was at 0.4.0. The README records that every upstream member in scope has a Rust counterpart or a documented waiver: 30,354 present and 5,856 waived.
use book_error::Result;
use ferroui::prelude::*;
use std::cell::Cell;
use std::rc::Rc;
// Avalonia's class hierarchy, carried into Rust: an App "derives" from
// Application through macros, and overrides virtual methods via a trait.
#[repr(C)]
pub struct App {
base: Application,
}
ferro_class!(App: Application);
ferro_impl_classes!(App: FerroObjectImpl);
impl NewApplication for App {
fn new_application() -> Ref<Self> {
instantiate(Self { base: Application::construct() })
}
}
impl ApplicationImpl for App {
fn initialize(this: &Self) {
Self::parent_initialize(this);
this.styles().add(FluentTheme::new().as_style());
}
fn on_framework_initialization_completed(this: &Self) {
let lifetime = this.application_lifetime();
if let Some(desktop) = lifetime.as_ref().and_then(|l| l.as_classic_desktop_style_application_lifetime()) {
desktop.set_main_window(Some(main_window()));
}
Self::parent_on_framework_initialization_completed(this);
}
}
// Controls are retained objects with setters, events and a children
// collection, exactly as in C# Avalonia (or WPF before it).
fn main_window() -> Ref<Window> {
let text = TextBlock::new();
text.set_text(Some("Hello from FerroUI"));
let clicks = Rc::new(Cell::new(0u32));
let button = Button::new();
button.set_content(Some(Rc::new("Click me".to_string())));
button.click({
let text = text.clone();
move |_, _| {
clicks.set(clicks.get() + 1);
text.set_text(Some(format!("Clicked {} times", clicks.get()).as_str()));
}
});
let panel = StackPanel::new();
panel.set_spacing(12.0);
panel.children().add(text);
panel.children().add(button);
let window = Window::new();
window.set_title(Some("FerroUI".to_string()));
window.set_content(Some(Control::boxed(panel)));
window
}
fn main() -> Result<()> {
let args: Vec<String> = std::env::args().skip(1).collect();
match AppBuilder::configure::<App>().use_platform_detect().start_with_classic_desktop_lifetime(&args) {
0 => Ok(()),
code => Err(std::io::Error::other(format!("exited with code {code}")).into()),
}
} The code looks unlike anything else in this book, and that is intended. Avalonia is object-oriented. Applications subclass Application, controls are retained objects with properties, events and child collections, and styling uses selectors and control themes. FerroUI rebuilds that class hierarchy in Rust with macros (ferro_class!) and *Impl traits for the virtual methods. It comes with what a WPF developer expects: data binding, a XAML compiler that turns markup into Rust in a build script, Fluent, WinUI 3, macOS 26 and Material themes, developer tools on F12, and MVVM libraries. Version 0.4 added a second way to write UI: ferroui-view, with an rsx! macro, signals and React-style hooks.
Its lockfile is the most independent in this book, with 189 packages and none of the shared layers: no winit, no wgpu, no Taffy, no Parley and no AccessKit. Rendering goes through Skia (skia-safe 0.153.3, with Vello as an experimental alternative backend), text shaping through HarfBuzz, and each platform has its own window, input and accessibility layer (UI Automation on Windows, AT-SPI on Linux). The first build downloads a prebuilt Skia and compiles HarfBuzz with a C++ compiler. The README is unusually precise about how it was tested: in CI, VMs, the iOS simulator and the Android emulator, but "not on a range of real devices", and no screen reader has been checked.