AsyncNavigation 2.0.2

dotnet add package AsyncNavigation --version 2.0.2
                    
NuGet\Install-Package AsyncNavigation -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" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsyncNavigation" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="AsyncNavigation" />
                    
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 --version 2.0.2
                    
#r "nuget: AsyncNavigation, 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@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&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=AsyncNavigation&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 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on AsyncNavigation:

Package Downloads
AsyncNavigation.Avalonia

A lightweight asynchronous navigation framework based on Microsoft.Extensions.DependencyInjection

AsyncNavigation.Wpf

A lightweight asynchronous navigation framework based on Microsoft.Extensions.DependencyInjection

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 125 5/19/2026
2.0.1 133 4/20/2026
2.0.0-beta 125 3/20/2026
1.1.0 942 12/11/2025
1.0.1 224 10/30/2025
1.0.0 203 10/21/2025
0.0.2-beta 185 10/17/2025
0.0.1-beta 207 10/14/2025