ReactiveUI.Uno 22.1.8

Prefix Reserved
dotnet add package ReactiveUI.Uno --version 22.1.8
                    
NuGet\Install-Package ReactiveUI.Uno -Version 22.1.8
                    
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="ReactiveUI.Uno" Version="22.1.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReactiveUI.Uno" Version="22.1.8" />
                    
Directory.Packages.props
<PackageReference Include="ReactiveUI.Uno" />
                    
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 ReactiveUI.Uno --version 22.1.8
                    
#r "nuget: ReactiveUI.Uno, 22.1.8"
                    
#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 ReactiveUI.Uno@22.1.8
                    
#: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=ReactiveUI.Uno&version=22.1.8
                    
Install as a Cake Addin
#tool nuget:?package=ReactiveUI.Uno&version=22.1.8
                    
Install as a Cake Tool

Build Code Coverage #yourfirstpr alternate text is missing from this package README image NuGet

<br> <a href="https://github.com/reactiveui/reactiveui"> <img width="160" heigth="160" src="https://raw.githubusercontent.com/reactiveui/styleguide/master/logo/main.png"> </a> <br>

ReactiveUI for Uno Platform

This package provides ReactiveUI bindings for the Uno Platform, enabling you to build composable, cross-platform model-view-viewmodel (MVVM) applications that run on iOS, Android, WebAssembly, macOS, and Windows.


NuGet Packages

To get started, install the following package into your shared Uno Platform project.

Platform NuGet
Platform Uno NuGet

Tutorial: Mastering ReactiveUI with the Uno Platform

Welcome to the ReactiveUI.Uno guide! This tutorial will walk you through setting up a cross-platform application using the Uno Platform with the power of ReactiveUI. We'll start from the basics and build up to a fully reactive application.

ReactiveUI.Uno provides the necessary bindings and helpers to seamlessly integrate the ReactiveUI MVVM framework with your Uno Platform projects, enabling you to write elegant, testable, and maintainable code.

Chapter 1: Getting Started - Your First Reactive View

Let's begin by setting up your project and creating your first reactive view and view model.

1. Installation

First, ensure you have the Uno Platform templates installed and create a new application. Then, add the ReactiveUI.Uno package to your project's shared csproj file.

<PackageReference Include="ReactiveUI.Uno" Version="21.0.1" />
2. Initialization

Next, initialize ReactiveUI in your App.cs startup code. This wires up the necessary services for the Uno Platform.

using ReactiveUI;
using Splat;

public App()
{
    // ... existing initialization ...

    var builder = Splat.AppLocator.CurrentMutable.CreateReactiveUIBuilder();
    builder
        .WithUno() // This extension method initializes ReactiveUI for Uno
        .Build();

    // ... more initialization ...
}
3. Create a ViewModel

Create a simple view model. Notice how it inherits from ReactiveObject and uses RaiseAndSetIfChanged to notify the UI of property changes.

// MyViewModel.cs
using ReactiveUI;

public class MyViewModel : ReactiveObject
{
    private string _greeting;

    public string Greeting
    {
        get => _greeting;
        set => this.RaiseAndSetIfChanged(ref _greeting, value);
    }

    public MyViewModel()
    {
        Greeting = "Hello, Reactive World!";
    }
}
4. Create a Reactive View

Now, let's create a view that binds to this view model. ReactivePage<TViewModel> is a base class that makes this easy.

<rxui:ReactivePage
    x:Class="MyUnoApp.MainPage"
    x:TypeArguments="local:MyViewModel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyUnoApp"
    xmlns:rxui="using:ReactiveUI.Uno"
    mc:Ignorable="d">

    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <TextBlock x:Name="GreetingTextBlock" FontSize="24" />
    </StackPanel>
</rxui:ReactivePage>

In the code-behind, use WhenActivated to set up your bindings. This is the core of a reactive view.

// MainPage.xaml.cs
using ReactiveUI;
using System.Reactive.Disposables;

public sealed partial class MainPage : ReactivePage<MyViewModel>
{
    public MainPage()
    {
        this.InitializeComponent();
        ViewModel = new MyViewModel();

        this.WhenActivated(disposables =>
        {
            // Bind the Greeting property of the ViewModel to the Text of the TextBlock
            this.OneWayBind(ViewModel,
                viewModel => viewModel.Greeting,
                view => view.GreetingTextBlock.Text)
                .DisposeWith(disposables);
        });
    }
}

Congratulations! You've just created your first reactive UI with ReactiveUI.Uno. When you run the app, you'll see the greeting message displayed.

Chapter 2: Handling User Interaction with ReactiveCommands

Static text is great, but apps need to respond to users. ReactiveCommand is the standard way to handle user actions like button clicks in a testable and composable way.

1. Add a Command to the ViewModel

Let's add a command to our view model that generates a new greeting.

// MyViewModel.cs
using ReactiveUI;
using System;
using System.Reactive;

public class MyViewModel : ReactiveObject
{
    // ... Greeting property from before ...

    public ReactiveCommand<Unit, Unit> GenerateGreetingCommand { get; }

    public MyViewModel()
    {
        Greeting = "Hello, Reactive World!";

        GenerateGreetingCommand = ReactiveCommand.Create(() =>
        {
            Greeting = $"Hello from Uno! The time is {DateTime.Now.ToLongTimeString()}";
        });
    }
}
2. Bind the Command in the View

Now, add a button to your XAML and bind its Command property to the new command.

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
    <TextBlock x:Name="GreetingTextBlock" FontSize="24" />
    <Button x:Name="GenerateGreetingButton" Content="Generate" Margin="0,20,0,0" />
</StackPanel>

Update your WhenActivated block to bind the button to the command.

// MainPage.xaml.cs
this.WhenActivated(disposables =>
{
    // ... existing binding ...

    // Bind the GenerateGreetingButton to the GenerateGreetingCommand
    this.BindCommand(ViewModel,
        viewModel => viewModel.GenerateGreetingCommand,
        view => view.GenerateGreetingButton)
        .DisposeWith(disposables);
});

Now, when you click the button, the command will execute, the Greeting property will change, and the UI will automatically update.

Chapter 3: Navigating with RoutedViewHost

For more complex applications, you'll need navigation. RoutedViewHost is a control that displays a view based on the current state of a RoutingState object.

1. Set up a Router

In your main view model (or a dedicated routing service), create a RoutingState.

// AppViewModel.cs
public class AppViewModel : ReactiveObject, IScreen
{
    public RoutingState Router { get; } = new RoutingState();

    public AppViewModel()
    {
        // Navigate to the initial view model
        Router.Navigate.Execute(new MyViewModel());
    }
}
2. Use RoutedViewHost in your Main Window

In your main window's XAML, replace the content with a RoutedViewHost and bind its Router property.

<Window ...>
    <Grid>
        <rxui:RoutedViewHost Router="{Binding Router}" />
    </Grid>
</Window>

You'll also need a way to tell RoutedViewHost which view to create for a given view model. This is done by registering views for your view models in your App.cs.

// App.cs
Locator.CurrentMutable.Register(() => new MainPage(), typeof(IViewFor<MyViewModel>));

Now, as you call Router.Navigate.Execute(...), the RoutedViewHost will automatically switch to the correct view.

This tutorial has covered the basics of getting started with ReactiveUI.Uno. You've learned how to set up your project, create reactive view models and views, handle user interaction with commands, and manage navigation. From here, you can explore more advanced ReactiveUI features like WhenAnyValue, ObservableAsPropertyHelper, and more complex command scenarios.


Thanks

We want to thank the following contributors and libraries that help make ReactiveUI.Uno possible:

Core Libraries

  • Uno Platform: Uno Platform - The underlying cross-platform UI framework.
  • System.Reactive: Reactive Extensions for .NET - The foundation of ReactiveUI's asynchronous API.
  • Splat: Splat - Cross-platform utilities and service location.
  • ReactiveUI: ReactiveUI - The core MVVM framework.

Sponsorship

The core team members, ReactiveUI contributors and contributors in the ecosystem do this open-source work in their free time. If you use ReactiveUI, a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

Become a sponsor.

This is how we use the donations:

  • Allow the core team to work on ReactiveUI
  • Thank contributors if they invested a large amount of time in contributing
  • Support projects in the ecosystem

Support

If you have a question, please see if any discussions in our GitHub Discussions or GitHub issues have already answered it.

If you want to discuss something or just need help, here is our Slack room, where there are always individuals looking to help out!

Please do not open GitHub issues for support requests.


Contribute

ReactiveUI.Uno is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use.

If you want to submit pull requests please first open a GitHub issue to discuss. We are first time PR contributors friendly.

See Contribution Guidelines for further information how to contribute changes.


License

ReactiveUI.Uno is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-android35.0 is compatible.  net9.0-browser was computed.  net9.0-browserwasm1.0 is compatible.  net9.0-desktop1.0 is compatible.  net9.0-ios was computed.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows10.0.19041 is compatible.  net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-browserwasm1.0 is compatible.  net10.0-desktop1.0 is compatible.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ReactiveUI.Uno:

Package Downloads
Zafiro.Uno

Goodies for Uno Platform

Zafiro.UI.Infrastructure.Uno

Infrastructure for Uno Platform apps

Zafiro.Uno.Controls

Common controls for Uno Platform

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
22.1.8 123 2/22/2026
22.1.0-beta.1 53 2/6/2026
20.0.36 461 9/18/2024
20.0.1 289 5/2/2024
19.1.34 650 1/2/2024
19.1.25 672 10/7/2023
19.1.1 906 6/18/2023
18.3.17 910 4/16/2023
18.3.7 968 2/1/2023
18.1.20 1,153 9/17/2022
18.1.2 1,294 7/3/2022
18.1.1 1,168 7/3/2022
17.1.50 2,540 2/14/2022
17.1.46 1,349 2/13/2022
17.1.17 1,414 1/1/2022
17.1.9 1,471 12/11/2021
17.1.6 1,270 12/6/2021
17.1.4 1,095 12/4/2021
16.4.15 1,093 12/13/2021
16.4.14 1,192 12/13/2021
Loading failed