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
<PackageReference Include="UXDivers.Navigation.Avalonia" Version="0.8.1" />
<PackageVersion Include="UXDivers.Navigation.Avalonia" Version="0.8.1" />
<PackageReference Include="UXDivers.Navigation.Avalonia" />
paket add UXDivers.Navigation.Avalonia --version 0.8.1
#r "nuget: UXDivers.Navigation.Avalonia, 0.8.1"
#:package UXDivers.Navigation.Avalonia@0.8.1
#addin nuget:?package=UXDivers.Navigation.Avalonia&version=0.8.1
#tool nuget:?package=UXDivers.Navigation.Avalonia&version=0.8.1
UXDivers Avalonia Navigation Framework
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
Navigation System
- 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:
- Scopes Guide - Understanding and configuring scopes
- Navigation Guide - Outlet-based navigation patterns
- Outlet Handlers - Extending navigation to support custom controls
- Service Registration - Registering views, ViewModels, and services
Architecture
Core Concepts
- ServiceLocator: Global access point to the root service provider
- Scopes: Isolated service containers that can be attached to controls
- Outlets: Named navigation targets within your UI
- Navigation Registry: Maps view names to view types and ViewModels
- 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:
- UXDivers.Avalonia.TestApp - Manual service container setup
- 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 | Versions 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. |
-
net10.0
- Avalonia (>= 11.3.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
-
net9.0
- Avalonia (>= 11.3.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
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 |