Sanet.MVVM.Navigation.Avalonia 1.7.12200

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

Sanet.MVVM.Navigation.Avalonia

Avalonia v12 implementations of INavigationService for classic desktop and single-view application lifetimes.

Installation

dotnet add package Sanet.MVVM.Navigation.Avalonia

Minimal usage

Classic desktop lifetime (IClassicDesktopStyleApplicationLifetime):

using Sanet.MVVM.Navigation.Avalonia.Services;

var navigation = new NavigationService(desktopLifetime, serviceProvider);

navigation.RegisterViews(typeof(MainView), typeof(MainViewModel));
await navigation.ShowViewModelAsync<MainViewModel>();

Single-view lifetime (ISingleViewApplicationLifetime):

var navigation = new SingleViewNavigationService(
    singleViewLifetime,
    contentControl,
    serviceProvider);

navigation.RegisterViews(typeof(MainView), typeof(MainViewModel));

Prerequisites

  • The host must already show an initial IBaseView. NavigationService reads and writes IClassicDesktopStyleApplicationLifetime.MainWindow.Content.
  • SingleViewNavigationService assigns the supplied ContentControl to ISingleViewApplicationLifetime.MainView and reads and writes that control's Content.
  • Register each pair with RegisterViews(viewType, viewModelType). The view type comes first.
  • Views must have a public parameterless constructor because the service creates them with Activator.CreateInstance.
  • View models must be resolvable from the supplied IServiceProvider for the parameterless navigation overloads, for example ShowViewModelAsync<T>().
  • The application owns the IServiceProvider. Sanet.MVVM.DI.Avalonia stores an IServiceCollection but does not build a provider.

Behavior

  • ShowViewModelAsync(viewModel) and ShowViewModelAsync<T>() perform ordinary navigation: the current view is pushed onto a back stack and replaced as the main content. This is not a modal dialog.
  • NavigateBackAsync() pops the back stack and restores the previous view.
  • NavigateToRootAsync() restores the bottom view of the back stack.
  • ShowViewModelForResultAsync<T, TResult>(viewModel) displays the view in Avalonia's OverlayLayer, waits for IResultProvider<TResult>.GetResultAsync(), and returns its result. It requires the current view to be an Avalonia Control with a TopLevel.
  • AskForActionAsync(title, description, actions) shows an overlay dialog and returns the selected UiAction. It does not execute the action's Command; the caller decides what to do.
  • UI work is dispatched through Dispatcher.UIThread.

Notes and limitations

  • CloseAsync() is not implemented and throws NotImplementedException.
  • The navigation service creates and caches view models. A view-model type that the provider cannot resolve makes the parameterless navigation overloads throw InvalidOperationException.
  • Register each view/view-model mapping once; RegisterViews uses a dictionary Add and duplicate registrations throw.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Sanet.MVVM.Navigation.Avalonia:

Package Downloads
Sanet.MakaMek.Avalonia

Avalonia UI frontend for MakaMek game

Sanet.MekForge.Avalonia

Avalonia UI frontend for MekForge game

Sanet.MakaMek.MapEditor

Map editor for MakaMek

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.12200 354 11/24/2026
1.7.1216 2,102 11/10/2026
1.7.1215 193 11/7/2026
1.7.1214 2,027 10/10/2026
1.7.1211 3,297 8/3/2026
1.6.1210 946 7/14/2026
1.5.1213 111 10/7/2026
1.5.1203 2,991 5/28/2026
1.5.1200 2,440 4/8/2026
1.4.11383 4,117 10/24/2025
1.4.11382 305 10/23/2025
1.4.11380 291 10/23/2025
1.3.11372 324 10/22/2025
1.3.1137 292 10/22/2025
1.2.1137 584 10/14/2025
1.1.1.1113 6,071 9/30/2024
1.1.1.1105 449 11/14/2023
1.1.0.1105 236 11/14/2023
1.1.0.1103 360 8/13/2023
1.0.11 406 7/9/2023
Loading failed