Skip to sessions and notes

These session notes are AI-generated and may contain mistakes. Verify important details against the original recording.

No XAML Required: Native Windows Apps in Pure C#

Alex

Session · 29:46 recording · 8 min read

At a glance

  • Microsoft.UI.Reactor: functional reactive MVU (UI = f(State)) native Windows framework
  • No XAML, no code-behind, no ViewModels, no INotifyPropertyChanged
  • Emits authentic WinUI 3 controls (real DirectX hardware composition, Mica backdrops, Narrator accessibility)
  • Single-file C# native desktop applications running directly via dotnet run
  • State management: UseState with numbered slots; UseReducer with immutable records & pure reducer functions

Executive Summary

At .NET Conf 2026, Alex from the Windows team presented Microsoft.UI.Reactor, an experimental open-source framework (MIT) that brings the Model-View-Update (MVU) functional reactive paradigm directly to native Windows development in pure, idiomatic C#.

For decades, Windows desktop development has relied heavily on declarative XAML markup paired with code-behind and MVVM (INotifyPropertyChanged, commands, two-way data bindings). UI Reactor completely removes the need for XAML files, .xaml.cs code-behind, and view models. Entire native Windows applications can now be written as a single C# file and executed directly via dotnet run.

Crucially, Reactor is not a new UI platform, not a new renderer, and not a fork of WinUI. When developers declare a button, title bar, or grid in Reactor, it creates and reconciles real WinUI 3 controls backed by GPU acceleration, native Mica/Acrylic material backdrops, system dark/light mode syncing, and full Windows Narrator accessibility.

The session demonstrated Reactor's reactive architecture (UseState and UseReducer), numbered state slot reconciliation, compile-time Roslyn analyzers enforcing the "Rules of Hooks", bi-directional interoperability with existing XAML and WinForms apps, state-preserving Hot Reload (winapp run --watch), and structured CLI DevTools (winapp devtools inspect) designed for autonomous AI coding agents.


1. What is UI Reactor? The Three Pillars

Title: No XAML Required: Native Windows Apps in Pure C#
Title: No XAML Required: Native Windows Apps in Pure C#

What is Reactor? MVU Pillars
What is Reactor? MVU Pillars

Microsoft.UI.Reactor is defined by three core principles:

  1. Model-View-Update (MVU): The user interface is a pure function of state: UI = f(State). Developers familiar with React, SwiftUI, or Jetpack Compose will immediately recognize this functional reactive architecture. It provides an alternative to MVVM with different trade-offs on the same platform.
  2. Real Native WinUI 3 Underneath: There is no intermediate canvas or custom graphics renderer. Calling Button() in Reactor instantiates an authentic Microsoft.UI.Xaml.Controls.Button. The application inherits full system accessibility, native touch/mouse/pen input, and DirectX hardware composition.
  3. Open-Source Experimentation: Built openly on GitHub under the MIT license, Reactor serves as an incubation playground for new desktop patterns and controls that can eventually graduate into official WinUI releases.
flowchart TD
    subgraph ReactiveCode["Declarative C# Application"]
        State["State (UseState / UseReducer)"]
        Render["Render() Method (Pure C# Description)"]
        Action["User Dispatches Action"]
    end

    subgraph ReactorCore["Microsoft.UI.Reactor Engine"]
        Slots["Numbered Slots (Call-order State Tracking)"]
        Reconciler["Keyed Diff Reconciler (Minimal Mutation Path)"]
        Analyzers["62+ Roslyn Compile-Time Analyzers"]
    end

    subgraph NativeWinUI["Native Windows Platform"]
        WinUIControls["Real WinUI 3 Controls (Buttons, Grids, Mica)"]
        Accessibility["Windows Accessibility & Narrator"]
        DirectX["DirectX Hardware Composition"]
    end

    State --> Render
    Render --> Reconciler
    Reconciler -->|"Patches Only Diffs"| WinUIControls
    WinUIControls --> Action
    Action --> Slots
    Slots --> State
    WinUIControls --> Accessibility
    WinUIControls --> DirectX

2. The Single-File C# Native Desktop Application

Single-File C# Application
Single-File C# Application

Using .NET file-based application directives, a complete native Windows desktop application can be stored in a single .cs file without a .csproj or XAML file:

// counter.cs
#:package Microsoft.UI.Reactor@preview
#:property UseWinUI=true

using Microsoft.UI.Reactor;

ReactorApp.Run<CounterApp>();

public class CounterApp : Component
{
    public override VisualNode Render()
    {
        var (count, setCount) = UseState(0);

        return Window(
            TitleBar("Pure C# WinUI Counter"),
            Column(
                Heading($"Count: {count}"),
                Row(
                    Button("-").OnClick(() => setCount(count - 1)),
                    Button("+").Accent().OnClick(() => setCount(count + 1))
                )
            ).Mica()
        );
    }
}

Running dotnet run counter.cs compiles and launches an authentic, packaged WinUI 3 window with full Mica backdrop styling and accent buttons:

Running Pure C# Counter App
Running Pure C# Counter App


WinApp New Reactor Templates
WinApp New Reactor Templates

For multi-file production applications, the WinApp CLI (winget install winapp) provides five experimental Reactor project templates:

# Interactive project generator with Reactor templates
winapp new

Templates include Blank App, Navigation View App, Class Library, Unit Test App, and complete Application Shells.

Reactor WinUI Gallery
Reactor WinUI Gallery

The team published the Reactor WinUI Gallery featuring over 93 live pages showcasing controls, docking panes, media players, and a native Reactor high-density DataGrid with grouping, column sorting, and instant dark/light theme switching.


4. State Architecture: Numbered Slots & UseReducer

State Management: UseState & Numbered Slots
State Management: UseState & Numbered Slots

Where Does State Live Without ViewModels?

State is preserved within the component instance across render passes using numbered slots:

  • var (count, setCount) = UseState(0);
  • count is a simple C# int primitive—not an ObservableProperty or INotifyPropertyChanged wrapper.
  • Invoking setCount(newVal) updates slot #0 and schedules a render pass.
  • When Render() executes, Reactor diffs the new visual tree description against the live WinUI controls and updates only the specific text property that changed.

Scaling State with UseReducer

UseReducer Minesweeper Architecture
UseReducer Minesweeper Architecture

For complex screens with interdependent state transitions, Reactor provides UseReducer:

// State and Action modeled as immutable C# records
public record MinesweeperState(Cell[,] Board, GameStatus Status, int FlagsRemaining);

public abstract record Action;
public record RevealCell(int Row, int Col) : Action;
public record ToggleFlag(int Row, int Col) : Action;
public record ResetGame : Action;

// Pure Reducer Function: (State, Action) => NextState
public static MinesweeperState Reducer(MinesweeperState state, Action action) => action switch
{
    RevealCell(var r, var c) => state.Reveal(r, c),
    ToggleFlag(var r, var c) => state.ToggleFlag(r, c),
    ResetGame => MinesweeperState.NewGame(),
    _ => state
};

Key Benefit: Because the reducer is a pure C# function completely decoupled from UI dispatchers and Windows controls, the entire game engine and every state transition can be 100% unit tested in headless CLI test runners without initializing a Window.


5. The "Rules of Hooks" & Roslyn Analyzers

Rules of Hooks: Slot Ordering
Rules of Hooks: Slot Ordering

Because state is mapped to numbered slots by invocation call order, developers must adhere to the Rules of Hooks:

  • Never call hooks (UseState, UseReducer, UseEffect) conditionally.
  • Do not place hooks inside if statements, inside for/foreach loops, or after early return statements.
  • Rule: Always execute the hook unconditionally and branch on the resulting values.

62+ Roslyn Analyzers for Reactor
62+ Roslyn Analyzers for Reactor

To prevent runtime slot mismatches, Reactor ships with 62+ Roslyn Analyzers providing instant red squiggles as developers type:

  • Flags hooks called inside loops or conditionals.
  • Warns when collections are mapped without a stable .WithKey().
  • Detects hardcoded colors that fail contrast checks in dark mode.
  • Warns on icon-only buttons missing screen-reader accessibility labels.
  • Detects background thread UI mutations before they trigger marshaling crashes.
  • Includes a "Did you mean?" fixer (e.g., catching typos in control names).

6. Lists, Keys, and Reconciliation Performance

Lists, Keys & Reconciliation Algorithm
Lists, Keys & Reconciliation Algorithm

In a 16x16 Minesweeper grid (256 interactive cells), clicking a blank space can flip 200 cells in a single action. Without keys, reconcilers compare elements strictly by index position, causing full layout churn and lost focus.

By attaching .WithKey($"{r}_{c}"), Reactor tracks items by stable identity:

  • Inserting a new row at index 0 of a 1,000-item list creates 1 control and moves 0 existing controls.
  • Screen readers receive structured automation names ($"Row {r}, Column {c}").

7. Bi-Directional Interoperability with XAML & WinForms

Bi-directional XAML & WinForms Interop
Bi-directional XAML & WinForms Interop

Reactor is designed for gradual, risk-free adoption without full application rewrites:

Hosting Reactor inside XAML

<!-- In existing MainWindow.xaml -->
<Page xmlns:reactor="using:Microsoft.UI.Reactor">
    <Grid>
        <!-- Embeds pure C# Reactor component directly inside XAML layout -->
        <reactor:ReactorHost Component="MyPureCSharpDashboard" />
    </Grid>
</Page>

Hosting XAML inside Reactor

// In Reactor Render() method
Window(
    Column(
        Heading("Pure C# Header"),
        // Embed legacy XAML UserControl or 3rd-party control
        XamlHost<LegacyCustomerControl>()
    )
)

An interop package is also provided for Windows Forms, allowing developers to modernize legacy enterprise desktop apps one panel at a time.


8. Hot Reload & Agentic DevTools Protocol

DevTools Hot Reload Watch
DevTools Hot Reload Watch

Running winapp run --watch provides live Hot Reload:

  • Modifying font scales or layout padding updates the UI in real time while preserving the active game board state, flagged cells, and timer.

Agent Tools: Inspect, Get-State, Set-State
Agent Tools: Inspect, Get-State, Set-State

Agent-Ready Headless CLI Protocol

Reactor exposes its internal component and hook registry to autonomous AI coding agents via winapp devtools:

  • winapp devtools inspect: Outputs the component hierarchy annotated with exact C# file paths and line numbers, allowing agents to precisely locate source code.
  • winapp devtools get-state: Dumps hook names, types, and values (with passwords automatically redacted).
  • winapp devtools set-state: Allows agents to programmatically inject state for UI testing.

9. Production Ecosystem & Cross-Platform Reach

Production Ecosystem: OpenClaw, Uno Platform, and Rust
Production Ecosystem: OpenClaw, Uno Platform, and Rust

Reactor has expanded beyond Microsoft research into production applications:

  • OpenClaw: The open-source Windows companion app ships Reactor in production for its real-time chat interface.
  • Uno Platform Port: Experimental Uno port runs identical Reactor C# components across macOS, Linux, WebAssembly, Android, and iOS without changing a single line of UI code.
  • Rust Port: Experimental implementation in the windows-reactor repository demonstrating the same MVU architecture in native Rust.

Key Takeaways

Feature Microsoft.UI.Reactor Capability
Architecture Functional Reactive MVU (UI = f(State)); zero XAML, zero INotifyPropertyChanged.
Native Controls Emits real WinUI 3 controls; DirectX composition, Mica backdrops, system accessibility.
Single-File Apps Full desktop apps in a single .cs file runnable with dotnet run.
State Primitives UseState for local slots; UseReducer for complex, headlessly unit-testable state machines.
Safety Guardrails 62+ Roslyn analyzers catch conditional hooks, missing keys, and dark mode issues at compile time.
List Performance Keyed diff reconciler minimizes DOM/visual tree churn on large collection mutations.
Bi-directional Interop Host Reactor inside XAML; host XAML/WinForms controls inside Reactor.
Agentic Tooling winapp devtools inspect returns component trees with exact C# file and line mappings.
Cross-Platform Uno Platform port enables execution on macOS, Linux, WebAssembly, iOS, and Android.