Routeables.Uno
2.1.0
dotnet add package Routeables.Uno --version 2.1.0
NuGet\Install-Package Routeables.Uno -Version 2.1.0
<PackageReference Include="Routeables.Uno" Version="2.1.0" />
<PackageVersion Include="Routeables.Uno" Version="2.1.0" />
<PackageReference Include="Routeables.Uno" />
paket add Routeables.Uno --version 2.1.0
#r "nuget: Routeables.Uno, 2.1.0"
#:package Routeables.Uno@2.1.0
#addin nuget:?package=Routeables.Uno&version=2.1.0
#tool nuget:?package=Routeables.Uno&version=2.1.0
Routeables.Uno
The Uno Platform host of Routeables (Windows, Linux, macOS, WebAssembly, Android, iOS): the setup call, a routed view base, the region control and a list view for the menu. Targets .NET 10. It contains no XAML of its own.
dotnet add package Routeables.Uno
The package brings Routeables (routing, abstractions and the source generator): there is nothing else to add.
Set up
public App()
{
InitializeComponent();
Services = this.UseRouteables();
}
protected override void OnLaunched(LaunchActivatedEventArgs args) =>
_window = this.OpenMainWindow(new MainPage());
An application with a menu gives its menu view model: this.UseRouteables<MainViewModel>(r => ...).
The window can be opened by the same call: Services = this.UseRouteables(r => { /* your own services */ }, () => new MainPage(), window => window.Title = "My app"); in the constructor of App builds the container and creates the window as the application runs, with no OnLaunched to write.
OpenMainWindow creates the window, gives the page the menu as DataContext, selects the first entry and disposes the container when the window closes. For another window, call window.AttachRouteables().
A view
<routeables:RouteableFor x:Class="XAnimals.Uno.Views.DogDetailView"
xmlns:routeables="using:Routeables.Uno" ...>
<local:AnimalDetail />
</routeables:RouteableFor>
public sealed partial class DogDetailView : RouteableFor { public DogDetailView() => InitializeComponent(); }
A XAML root cannot be generic in WinUI, so XAML views use RouteableFor; views written in code can use RouteableFor<TViewModel>.
The menu is a RouteableMenuViewModelBase and <routeables:RouteableListView />; the page is shown by <routeables:RouteableRegion />. A region is <routeables:RouteableRegion Region="detail" />.
Bindable view models
Put [System.ComponentModel.Bindable(true)] above every view model a view binds to. It takes the place of the [Bindable] of the platform and lets the XAML compiler generate the binding code, so {Binding} and {x:Bind} do not use reflection at run time (needed for trimming and Native AOT).
// samples/Bases/XAnimals.Common/ViewModels/AnimalsViewModel.cs
[System.ComponentModel.Bindable(true)]
[Routeable("/hello")]
public class HelloViewModel : ViewModelBase { public string Greeting => "Hello"; }
Without it a binding to the view model still works through reflection, which the trimmer may remove.
Navigation
A NavigationView written in XAML: each item names its route, and the router builds the page.
<NavigationView x:Name="Nav">
<NavigationViewItem Content="Cats" routeables:RouteableItem.Route="cats" />
<NavigationViewItem Content="Dogs" routeables:RouteableItem.Route="dogs" />
</NavigationView>
Nav.AttachRouteables(provider, region: "tabs"); // returns an IDisposable
Without region, the items follow the main history.
Dialogs and notifications
In the Routeables.Uno.Services namespace. UseRouteables already registers them; call UseRouteablesServices(sp => new MyMessageBoxService()) yourself only to draw them another way.
- Dialogs, content dialogs and task dialogs, drawn as
ContentDialogs in the window the user last worked in. A window shows one at a time; a second waits for the first. - Notifications:
InfoBars stacked at the top of the active window, closed after five seconds or by the user. DialogView<TViewModel, TResult>: the base of a modal view backed by a closeable view model, written in code (a WinUI XAML root cannot be generic). SeeNoteViewinsamples/XAnimals.Uno.IMessageBoxService(DefaultMessageBoxService): give a factory toUseRouteablesServices(sp => new MyMessageBoxService())to draw them another way.
Calling a service before a window has content throws an InvalidOperationException that says so. Contracts: Routeables.Services.
Good to know
- Routeables does not use
Frameor Uno.Extensions: do not mix them in one window. IsAotCompatibleis declared and the CI builds thenet10.0target with the analyzers (a trim or AOT warning fails the build). No trimmed Uno application is published or run there, and the Android and iOS heads are not built.- Images in the sample are fetched by Uno itself; Wikimedia may refuse them without a User-Agent.
Next
Hosts guide, sample samples/XAnimals.Uno.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-ios26.0 is compatible. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Routeables (>= 2.1.0)
- Uno.WinUI (>= 6.7.135)
-
net10.0-android36.0
- Routeables (>= 2.1.0)
- Uno.WinUI (>= 6.7.135)
-
net10.0-ios26.0
- Routeables (>= 2.1.0)
- Uno.WinUI (>= 6.7.135)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.