Navis.WinUI
0.9.3
See the version list below for details.
dotnet add package Navis.WinUI --version 0.9.3
NuGet\Install-Package Navis.WinUI -Version 0.9.3
<PackageReference Include="Navis.WinUI" Version="0.9.3" />
<PackageVersion Include="Navis.WinUI" Version="0.9.3" />
<PackageReference Include="Navis.WinUI" />
paket add Navis.WinUI --version 0.9.3
#r "nuget: Navis.WinUI, 0.9.3"
#:package Navis.WinUI@0.9.3
#addin nuget:?package=Navis.WinUI&version=0.9.3
#tool nuget:?package=Navis.WinUI&version=0.9.3
Navis.WinUI
Install the NuGet package:
dotnet add package Navis.WinUI
Navis.WinUI is a compact WinUI 3 navigation library for typed, nested, and declarative page navigation.
Quick usage
Register navigation with the application's service collection. INavigation injected while a page is being created is bound to the frame activating that page. When resolved elsewhere, it defers lookup until an operation or property is used, then targets the single loaded, enabled root frame on the calling UI thread.
using Navis.WinUI.Extensions;
services.AddNavisNavigation();
Enable navigation on a Frame and optionally provide its first page. XamlType converts a XAML type name to the Type expected by Navis:
<Page
xmlns:main="using:YourApp.Views"
xmlns:nav="using:Navis.WinUI">
<Frame
nav:NavigationHost.IsEnabled="True"
nav:NavigationHost.InitialPage="{nav:XamlType TypeName=main:HomePage}" />
</Page>
Use the contextual navigation service from a page or view model:
public sealed class HomeViewModel(INavigation navigation)
{
public void OpenDetails() => navigation.Navigate<DetailsPage>();
public void OpenOrder(Order order) =>
navigation.Navigate<DetailsPage, Order>(order);
}
Navigate<TPage>() navigates without a parameter. Navigate<TPage, TParameter>(parameter) passes a strongly typed value to the destination. Both methods also accept a NavigationKind such as Replace or Reset.
Receive a typed parameter and participate in the navigation lifecycle with INavigationAware<TParameter>:
public sealed class DetailsViewModel : INavigationAware<Order>
{
public ValueTask OnNavigatedToAsync(
Order order,
CancellationToken cancellationToken)
{
// Load the order.
return ValueTask.CompletedTask;
}
public ValueTask OnNavigatedFromAsync(CancellationToken cancellationToken) =>
ValueTask.CompletedTask;
}
XAML navigation
Attach navigation to a button or other button-based control. Navigate.To selects the page, Navigate.Kind selects the journal operation, and Navigate.Target selects the current, parent, or root navigation host:
<Button
xmlns:pages="using:YourApp.Views"
xmlns:nav="using:Navis.WinUI"
Content="Open details"
nav:Navigate.To="{nav:XamlType TypeName=pages:DetailsPage}"
nav:Navigate.Kind="Navigate"
nav:Navigate.Target="Current" />
Parameters can be bound in XAML with Navigate.Parameter:
<Button
nav:Navigate.Parameter="{x:Bind ViewModel.SelectedOrder}"
nav:Navigate.To="{nav:XamlType TypeName=pages:DetailsPage}" />
Caveats
INavigationresolved during page activation is bound to that frame. Deferred instances used outside activation require exactly one loaded, enabled root frame on the calling UI thread; zero or multiple roots throw. Deferred instances do not capture a frame, queue operations, or dispatch to another UI thread.- Navigation must run on the frame's UI thread.
- Requests made while another navigation request is in flight are ignored.
- Typed parameters must match the destination's
INavigationAware<TParameter>type at runtime. Navigate.Target="Parent"requires a nested navigation host with a parent frame.Rootresolves the top-level host, so parent/root routing requires the corresponding nested-frame structure.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.19041 is compatible. |
-
net10.0-windows10.0.19041
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Windows.SDK.BuildTools (>= 10.0.28000.2526)
- Microsoft.WindowsAppSDK (>= 2.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.