StateManagementSharp.Maui 2.0.1

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

StateManagementSharp.Maui

StateManagementSharp.Maui is the .NET MAUI integration package for StateManagementSharp. It adds MAUI-friendly binding helpers on top of the UI-agnostic core store: StoreBindableObject, BindableValue<T>, and UseStateManagementSharp<TStore>().

What this package adds

  • UseStateManagementSharp<TStore>() — a MauiAppBuilder extension that registers the StateManagementSharp core services and your store in one call.
  • StoreBindableObject — a base class for reactive MAUI view models that project store state into bindable values.
  • BindableValue<T> — a bindable holder you expose to XAML; assigning its Value raises PropertyChanged.
  • Automatic UI-thread marshaling for values bound with Bind(...), so a state change committed on any thread reaches the UI safely.
  • Fody integration, internal to the package, that weaves INotifyPropertyChanged into BindableValue<T> — you never reference Fody yourself.

Relationship with StateManagementSharp

  • StateManagementSharp.Maui depends on the core package StateManagementSharp.
  • The core stays UI-agnostic and provides the store, modules, actions, mutations, the StateChanged event, and Observe(...).
  • This package does not replace the core — it integrates with it, adding the MAUI binding layer.
  • Installing StateManagementSharp.Maui brings StateManagementSharp in transitively, so you don't install the core separately.

Installation

For a .NET MAUI app:

dotnet add package StateManagementSharp.Maui --version 2.0.1

You don't need to install StateManagementSharp as well — it is a dependency of this package and is restored automatically.

using Microsoft.Maui.Hosting;

builder
    .UseMauiApp<App>()
    .UseStateManagementSharp<InternalStore>();

UseStateManagementSharp<TStore>() is available through the standard MAUI namespace Microsoft.Maui.Hosting, and:

  • registers the StateManagementSharp core services;
  • scans an assembly for actions, defaulting to typeof(TStore).Assembly;
  • registers TStore as a singleton;
  • replaces the manual builder.Services.AddStateManagementSharp(...) setup.

Do not also call builder.Services.AddStateManagementSharp(...) for the same store in the same MauiProgram; UseStateManagementSharp<TStore>() already performs the core registration. (Pass explicit assemblies — UseStateManagementSharp<InternalStore>(extraAssembly) — only when your actions live outside the store's assembly.)

ViewModel usage

Derive the view model from StoreBindableObject and expose store selectors as BindableValue<T> properties:

public sealed class MainPageViewModel : StoreBindableObject
{
    public MainPageViewModel(InternalStore store, IDispatcher dispatcher)
        : base(dispatcher)
    {
        store.InitializeStore();

        FirstName = Bind(store.ProfileModule, state => state.FirstName);
        IsBusy = Bind(store.AppContextModule, state => state.IsBusy);

        LoadProfileCommand = new Command(async () =>
            await store.ProfileModule.Dispatch<LoadProfileAction>());
    }

    public BindableValue<string?> FirstName { get; }
    public BindableValue<bool> IsBusy { get; }
    public ICommand LoadProfileCommand { get; }
}

Commands only dispatch — there is no manual refresh. Bind(...) recomputes each value after every commit and pushes it to the UI thread for you.

XAML binding

Bind the .Value path of each BindableValue<T>:

<Label Text="{Binding FirstName.Value}" />
<ActivityIndicator IsRunning="{Binding IsBusy.Value}" />

Bind vs Observe

  • Bind(selector) — for values the UI displays (raw or derived). Returns a BindableValue<T>, recomputed on every commit and marshaled to the UI thread for you.
  • Observe(selector, onChanged) — for side-effects / reactions (logging, navigation, analytics, refreshing non-bound data). It runs on the thread that committed, so marshal yourself (for example via IDispatcher) if you touch the UI. Both are distinct-until-changed, so identical values don't fire.

Core-only setup

If you are not building a MAUI app, install the core package instead:

dotnet add package StateManagementSharp --version 2.0.1

and register it manually (AddStateManagementSharp(...) lives in the standard DI namespace Microsoft.Extensions.DependencyInjection):

using Microsoft.Extensions.DependencyInjection;

builder.Services.AddStateManagementSharp(typeof(InternalStore).Assembly);
builder.Services.AddSingleton<InternalStore>();

See the project README on GitHub for the full core documentation, the reactive model (StateChanged / Observe), and the 1.x → 2.0 migration guide.

Product Compatible and additional computed target framework versions.
.NET net10.0-android36.0 is compatible.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst26.0 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
2.0.1 124 7/3/2026
2.0.0 110 7/3/2026

2.0.1 is the first published MAUI integration package aligned with StateManagementSharp 2.0.1. It includes MAUI setup helpers, BindableValue<T>, StoreBindableObject, a dedicated NuGet README, and setup documentation for UseStateManagementSharp<TStore>().