Microsoft.UI.Reactor.Advanced 0.1.0-preview.5

Prefix Reserved
This is a prerelease version of Microsoft.UI.Reactor.Advanced.
dotnet add package Microsoft.UI.Reactor.Advanced --version 0.1.0-preview.5
                    
NuGet\Install-Package Microsoft.UI.Reactor.Advanced -Version 0.1.0-preview.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.UI.Reactor.Advanced" Version="0.1.0-preview.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.UI.Reactor.Advanced" Version="0.1.0-preview.5" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.UI.Reactor.Advanced" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.UI.Reactor.Advanced --version 0.1.0-preview.5
                    
#r "nuget: Microsoft.UI.Reactor.Advanced, 0.1.0-preview.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.UI.Reactor.Advanced@0.1.0-preview.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.UI.Reactor.Advanced&version=0.1.0-preview.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.UI.Reactor.Advanced&version=0.1.0-preview.5&prerelease
                    
Install as a Cake Tool

Microsoft.UI.Reactor.Advanced

Optional Reactor components with heavier native and graphics dependencies — starting with a Win2D canvas family for immediate-mode drawing inside a Reactor element tree.

About

Microsoft.UI.Reactor.Advanced extends Microsoft.UI.Reactor with components that pull in larger native or graphics stacks. Its first surface is a Win2D canvas family (manual, animated, and virtual) that lets you draw with CanvasDrawingSession directly from a declarative Reactor component.

This package is intentionally separate from the core framework so that apps which don't need Win2D keep their trim/AOT closure and native payload isolated.

How to Use

Install the package alongside Microsoft.UI.Reactor:

dotnet add package Microsoft.UI.Reactor.Advanced

Drop a Win2D canvas into any component. The onDraw callback runs on the UI thread with a CanvasDrawingSession; pass a redrawKey to trigger invalidation when your state changes:

using Microsoft.UI.Reactor;
using Microsoft.UI.Reactor.Core;
using Windows.UI;
using static Microsoft.UI.Reactor.Factories;          // core DSL
using static Microsoft.UI.Reactor.Advanced.Factories; // Win2D DSL

internal sealed class CanvasDemo : Component
{
    public override Element Render()
    {
        var (radius, setRadius) = UseState(40f);

        return VStack(12,
            Win2DCanvas(
                onDraw: (session, args) =>
                {
                    session.Clear(Colors.Black);
                    session.FillCircle(120, 120, radius, Colors.DeepSkyBlue);
                },
                redrawKey: radius),
            Button("Grow", () => setRadius(radius + 10f))
        ).Padding(24);
    }
}

When radius changes, the new redrawKey tells Reactor to invalidate the canvas and redraw.

Key Features

  • Win2DCanvas — manual-invalidate canvas (CanvasControl); redraws when its redrawKey changes.
  • Win2DAnimatedCanvas — game-loop canvas (CanvasAnimatedControl) whose update and draw callbacks run on the Win2D game thread.
  • Win2DVirtualCanvas — virtualized canvas (CanvasVirtualControl) for very large drawing surfaces.
  • Async resource creation — overloads accept an onCreateResources callback tracked by Win2D for loading bitmaps and other device resources.
  • Isolated native payload — keeps Win2D out of the core framework's trim/AOT closure.

Main Types

  • Win2DCanvas(...) — factory for a manual-invalidate Win2D canvas.
  • Win2DAnimatedCanvas(...) — factory for an animated game-loop canvas.
  • Win2DVirtualCanvas(...) — factory for a virtualized canvas.
  • Win2DCanvasElement — immutable element produced by Win2DCanvas.

Best Practices

  • Drive redraws with redrawKey. Pass the state that affects the drawing (or a composite of it) as redrawKey. The canvas only invalidates when the key changes, so avoid allocating a new key object on every render when nothing changed.
  • Create device resources in onCreateResources, not onDraw. Load bitmaps and other GPU resources in the resource callback so they survive device-lost events; the onDraw callback should stay allocation-free and fast.
  • Mind the thread for animated canvases. Win2DAnimatedCanvas invokes onUpdate/onDraw on the Win2D game thread, not the UI thread. Don't touch Reactor component state directly from those callbacks — pass data in through drawState and marshal back with a threadSafe: true state setter if you need to update the UI.
  • Keep Win2D optional. Reference this package only from the projects that need it so apps that don't draw keep a smaller trim/AOT closure and native payload.

Additional Documentation

Feedback & Contributing

Microsoft.UI.Reactor.Advanced is part of the open-source Reactor project. File issues, ask questions, and contribute on GitHub. See CONTRIBUTING.md to get started.

Support Policy

This package is currently released as a preview and is provided under the MIT License. APIs may change between preview releases.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.22621 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.5 39 6/12/2026
0.1.0-preview.4 83 6/11/2026
0.1.0-preview.3 55 6/10/2026