AsyncNavigation.Wpf 2.0.2

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

AsyncNavigation

A lightweight async navigation framework for .NET desktop apps, built on Microsoft.Extensions.DependencyInjection.

CI NuGet NuGet NuGet License: MIT .NET

中文文档 · Live Demo


Features

Async/Await Native Navigation is fully async end-to-end with CancellationToken support
DI-First Views and view models are resolved from the DI container
Navigation Guard Block navigation away with INavigationGuard (e.g. unsaved changes)
Interceptors Run cross-cutting logic (auth, analytics) via INavigationInterceptor
Dialog Service Async dialog and window management built-in
Multiple Region Types ContentControl, ItemsControl, and TabControl regions
History Navigation GoForwardAsync / GoBackAsync out of the box
Lifecycle Management Automatic view caching, eviction, and disposal — no memory leaks
Native AOT Full Avalonia AOT / trimming support, zero extra config
Framework-Agnostic Works with any MVVM framework
Minimal Deps Only Microsoft.Extensions.DependencyInjection.Abstractions >= 8.0

Installation

# Avalonia
dotnet add package AsyncNavigation.Avalonia

# WPF
dotnet add package AsyncNavigation.Wpf

Quick Start

1. Register services

services.AddNavigationSupport()
        .RegisterView<HomeView, HomeViewModel>("Home")
        .RegisterView<SettingsView, SettingsViewModel>("Settings")
        .RegisterDialog<ConfirmView, ConfirmViewModel>("Confirm");

2. Declare a region in XAML

xmlns:an="https://github.com/NeverMorewd/AsyncNavigation"

<ContentControl an:RegionManager.RegionName="MainRegion" />

3. Navigate

// Navigate
await _regionManager.RequestNavigateAsync("MainRegion", "Home");

// History
await _regionManager.GoBackAsync("MainRegion");
await _regionManager.GoForwardAsync("MainRegion");

// Dialog
var result = await _dialogService.ShowViewDialogAsync("Confirm");

4. React to navigation in view models

// Derive from NavigationAwareBase and override only what you need.
public class HomeViewModel : NavigationAwareBase
{
    public override async Task OnNavigatedToAsync(NavigationContext context)
    {
        await LoadDataAsync(context.CancellationToken);
    }
}

public class EditViewModel : NavigationAwareBase, INavigationGuard
{
    public async Task<bool> CanNavigateAsync(NavigationContext context, CancellationToken ct)
    {
        // Return false to cancel — show a confirmation dialog here if needed.
        return !HasUnsavedChanges;
    }
}

Interceptors

public class AuthInterceptor : INavigationInterceptor
{
    public Task OnNavigatingAsync(NavigationContext context)
    {
        if (!_auth.IsLoggedIn)
            throw new OperationCanceledException("Not authenticated.");
        return Task.CompletedTask;
    }

    public Task OnNavigatedAsync(NavigationContext context) => Task.CompletedTask;
}

// Register
services.AddNavigationSupport()
        .RegisterNavigationInterceptor<AuthInterceptor>();

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows7.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.2 92 5/19/2026
2.0.1 107 4/20/2026
2.0.0-beta 110 3/20/2026
1.1.0 444 12/11/2025
1.0.1 203 10/30/2025
1.0.0 191 10/21/2025
0.0.2-beta 167 10/17/2025
0.0.1-beta 187 10/14/2025