Avalon.Views.Navigation.Avalonia (0.1.0)
Installation
dotnet nuget add source --name Dutch --username your_username --password your_token dotnet add package --source Dutch --version 0.1.0 Avalon.Views.Navigation.AvaloniaAbout this package
Avalon views navigating library containing implementations for view locating and animated navigation for AvaloniaUI.
Avalon
Avalon provides reusable features and components to kickstart crossplatform applications with AvaloniaUI and MAUI (later on).
| Library | Decription | AvaloniaUI | MAUI |
|---|---|---|---|
| Avalon.Core | Core library with basic cross-framework implementations and abstractions. | ✅ | ✅️ |
| Avalon.Views.Core | Core library containing basic view related implementations and abstractions. | ✅️ | ✅ |
| Avalon.Views.Navigation | Simple navigation service. | ✅ | ❌ |
| Avalon.Views.PopUp | (planned) Simple popup service. | ❌ | ❌ |
| Avalon.Views.Controls | (planned) Reusable pages and controls. | ❌ | ❌ |
Note: MAUI support is planned, but currenly not scheduled.
Note: Always use the .Avalonia or .MAUI packages.
Avalon.Views.Navigation
This library provides implementations for view locating and animated navigation.
Features
ViewLocator
// Create the ViewLocator - a service locator may be passed optionally
var locator = new AvaloniaViewLocator();
// Resolve view
var view = locator.ResolveView<MainView, MainViewModel>()
Navigation
// Usage within another ViewModel:
// Push the resolved view
Navigation.PushAsync(view)
// Resolve a view and push simultaniuisly
Navigation.PushAsync<MyView, MyViewModel>()
Available methods
- PushAsync
- PopAsync
- PopToRootAsync
- SetRootAsync
Passing data on navigation
To pass data to another object when navigating, pass an instance of NavigationData (or custom implementation of INavigationData) to one of the available navigation methods.
The target object must either implement the INavigable or the IElementWithVm interface.
Initialization
Ensure that .UseViewHelper() is invoked as part of your AppBuilder initialization to activate the library’s functionality.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseViewHelper() // <- Add this line
.WithInterFont()
.LogToTrace();
License
MIT