UXDivers.Navigation.Avalonia 0.8.1

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

UXDivers Avalonia Navigation Framework

NuGet Downloads License

A powerful and flexible navigation framework for Avalonia applications, featuring scoped dependency injection, modular navigation, and MVVM support.

Overview

The UXDivers Avalonia Navigation Framework provides a comprehensive solution for building scalable Avalonia applications with:

  • Scoped Dependency Injection: Hierarchical service scopes that align with your UI structure
  • Outlet-Based Navigation: Navigate between views within defined outlets of your application
  • MVVM Support: First-class support for ViewModels with automatic resolution and lifecycle management
  • Cross-Platform: Works seamlessly across Desktop, Mobile (iOS/Android), and Browser platforms
  • Fluent API: Intuitive builder pattern for configuring navigation and scopes

Key Features

Scoped Dependency Injection

  • Create isolated service scopes for different parts of your application (windows, views, etc.)
  • Automatic scope propagation through the visual tree
  • Support for custom scope implementations
  • Efficient service resolution with parent scope fallback
  • Outlet-based navigation with support for multiple outlets per view
  • Modal and non-modal navigation
  • Navigation parameters and result handling
  • View and ViewModel lifecycle awareness (IActivatable, IInitializeAware)
  • Nested outlet support

Flexibility

  • Compatible with Microsoft.Extensions.DependencyInjection
  • Support for both manual service container setup and .NET Generic Host
  • Custom view/ViewModel resolution strategies

Quick Start

1. Install the NuGet Package

dotnet add package UXDivers.Popups.Maui

2. Basic App Setup

In your App.axaml.cs:

public class App : Application
{
    private IServiceProvider? _services;

    public override void Initialize()
    {
        base.Initialize();
        AvaloniaXamlLoader.Load(this);

        // Create and configure services
        var services = new ServiceCollection();
        ConfigureServices(services);
        
        // Build and initialize the service provider
        _services = services.BuildServiceProvider();
        ServiceLocator.Initialize(_services);
    }

    private void ConfigureServices(IServiceCollection services)
    {
        // Add navigation support
        services.AddNavigation(navigationBuilder =>
        {
            navigationBuilder.WithDefaultOutlet("MainOutlet");
            navigationBuilder.WithNavigationRegistry(registry =>
            {
                registry.RegisterView<HomeView>()
                    .WithViewModel<HomeViewModel>()
                    .AsOutletTarget("MainOutlet");
            });
        });
            
        // Register your windows
        services.AddTransient<MainWindow>();
    }
}

3. Define Outlets in XAML

<Window xmlns="https://github.com/avaloniaui"
        xmlns:uxd="https://uxdivers.com"
        x:Class="YourApp.MainWindow">

    <uxd:Shell uxd:NavigationService.OutletName="MainOutlet" />
</Window>

4. Navigate Between Views

public class HomeViewModel : ViewModelBase
{
    private readonly INavigationService _navigationService;

    public HomeViewModel(INavigationService navigationService)
    {
        _navigationService = navigationService;
    }

    private async Task NavigateToDetails()
    {
        await _navigationService.NavigateAsync("MainOutlet", "DetailsView");
    }
}

Documentation

Detailed documentation is available in the docs folder:

Architecture

Core Concepts

  1. ServiceLocator: Global access point to the root service provider
  2. Scopes: Isolated service containers that can be attached to controls
  3. Outlets: Named navigation targets within your UI
  4. Navigation Registry: Maps view names to view types and ViewModels
  5. Behaviors: Extensible hooks for customizing navigation and outlet behavior

Component Hierarchy

Application
  ├─ ServiceProvider (Global)
  │   └─ IScopeRegistry
  │
  └─ Windows/Views
      └─ Scope (Per Window/View)
          ├─ IOutletManager
          ├─ INavigationService
          └─ INavigationRegistry

Platform Support

  • ✅ Windows Desktop
  • ✅ macOS Desktop
  • ✅ Linux Desktop
  • ✅ iOS
  • ✅ Android
  • ✅ WebAssembly (Browser)

Requirements

  • .NET 8.0 or later
  • Avalonia 11.0 or later
  • Microsoft.Extensions.DependencyInjection

Examples

The repository includes two example applications:

  1. UXDivers.Avalonia.TestApp - Manual service container setup
  2. UXDivers.Avalonia.TestAppWithHost - Using .NET Generic Host

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For questions and support, please visit our website or open an issue in the repository.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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

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.8.1 484 12/16/2025