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" />
<PackageReference Include="Sanet.MVVM.Navigation.Avalonia" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Sanet.MVVM.Navigation.Avalonia&version=1.7.12200
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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.NavigationServicereads and writesIClassicDesktopStyleApplicationLifetime.MainWindow.Content. SingleViewNavigationServiceassigns the suppliedContentControltoISingleViewApplicationLifetime.MainViewand reads and writes that control'sContent.- 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
IServiceProviderfor the parameterless navigation overloads, for exampleShowViewModelAsync<T>(). - The application owns the
IServiceProvider.Sanet.MVVM.DI.Avaloniastores anIServiceCollectionbut does not build a provider.
Behavior
ShowViewModelAsync(viewModel)andShowViewModelAsync<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'sOverlayLayer, waits forIResultProvider<TResult>.GetResultAsync(), and returns its result. It requires the current view to be an AvaloniaControlwith aTopLevel.AskForActionAsync(title, description, actions)shows an overlay dialog and returns the selectedUiAction. It does not execute the action'sCommand; the caller decides what to do.- UI work is dispatched through
Dispatcher.UIThread.
Notes and limitations
CloseAsync()is not implemented and throwsNotImplementedException.- 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;
RegisterViewsuses a dictionaryAddand duplicate registrations throw.
Links
License
MIT. See LICENSE.
| Product | Versions 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.
-
net11.0
- Avalonia (>= 12.2.0)
- Sanet.MVVM.Core (>= 1.7.3)
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