Goldie.MauiPlugins.PageResolver
1.0.0
See the version list below for details.
dotnet add package Goldie.MauiPlugins.PageResolver --version 1.0.0
NuGet\Install-Package Goldie.MauiPlugins.PageResolver -Version 1.0.0
<PackageReference Include="Goldie.MauiPlugins.PageResolver" Version="1.0.0" />
<PackageVersion Include="Goldie.MauiPlugins.PageResolver" Version="1.0.0" />
<PackageReference Include="Goldie.MauiPlugins.PageResolver" />
paket add Goldie.MauiPlugins.PageResolver --version 1.0.0
#r "nuget: Goldie.MauiPlugins.PageResolver, 1.0.0"
#:package Goldie.MauiPlugins.PageResolver@1.0.0
#addin nuget:?package=Goldie.MauiPlugins.PageResolver&version=1.0.0
#tool nuget:?package=Goldie.MauiPlugins.PageResolver&version=1.0.0
MAUI PageResolver
A simple and lightweight page resolver for use in .NET MAUI projects.
While we're waiting for the full MVVM frameworks we know and love to be updated for MAUI, or if you just want a simple page resolver with DI without using a full MVVM framework (or if you want to use MVU), this package will let you navigate to fully resolved pages, with view models and dependencies, by calling:
await Navigation.PushAsync<MyPage>();
Getting Started
Step 1: Install Nuget package
Install the Nuget package
dotnet add package Goldie.MauiPlugins.PageResolver
Step 2: Register dependencies
Your services, view models, and pages all need to be registered in the service collection. Update the Configure method in your Startup.cs as follows
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Compatibility;
// Add reference to PageResolver
using Maui.Plugins.PageResolver;
// Add any required references to your services, view models, etc.
using MyApp.Services;
using MyApp.ViewModels;
using MyApp.Views;
namespace MyApp
{
public class Startup : IStartup
{
public void Configure(IAppHostBuilder appBuilder)
{
appBuilder
.UseFormsCompatibility()
.UseMauiApp<App>()
// Add ConfigureServices
.ConfigureServices(services =>
{
// register your services
services.AddSingleton<IMyService, MyService>();
// register your view models
services.AddTransient<MyViewModel>();
// register your views
services.AddTransient<MyPage>();
// register the page resolver
services.UsePageResolver();
})
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
}
}
}
Step 3: Inject your dependencies
Use constructor injection to add your dependencies to your pages and view models. E.g.:
public class MyPage
{
public MyViewModel ViewModel { get; set; }
public MyPage(MyViewModel viewModel)
{
ViewModel = viewModel;
BindingContext = ViewModel;
}
}
And in your view models:
public class MyViewModel
{
public IMyService Service { get; set; }
public MyViewModel(IMyService myService)
{
Service = myService;
}
}
Step 4: Use in your code
In your code, navigate to your page by calling:
await Navigation.PushAsync<MyPage>();
This will return a fully resolved instance of MyPage
including all dependencies.
Modal pages are also supported:
await Navigation.PushModalAsync<MyPage>();
Notes
This is just something I put together for myself (with some input from William Liebenberg), but thought it might be useful to others. If you use it and it's helpful, great. If not, please remember it's an early attempt at doing something useful for a preview version of MAUI. If you have comments or suggestions, feedback is welcome.
TODO
- Use reflection / code generation to automatically register pages and view models
- (Pending C# 10) Add a global using for this package
- Set up GitHub Action to publish package
- (Possibly) change namespace
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.Maui (>= 6.0.100-preview.5.753)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Goldie.MauiPlugins.PageResolver:
Package | Downloads |
---|---|
Goldie.MauiPlugins.PageResolver.MopupsExtensions
Mopups extensions for PageResolver - push popup pages with resolved dependencies |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Goldie.MauiPlugins.PageResolver:
Repository | Stars |
---|---|
matt-goldman/MauiCleanTodos
Clean Architecture with ASP.NET Core, .NET MAUI and Blazor
|
Version | Downloads | Last Updated |
---|---|---|
2.5.4 | 2,018 | 2/4/2025 |
2.5.3 | 285 | 12/27/2024 |
2.5.2 | 1,625 | 11/4/2024 |
2.5.1 | 895 | 11/2/2024 |
2.5.0 | 355 | 10/18/2024 |
2.0.1 | 4,463 | 11/18/2023 |
2.0.0 | 192 | 11/13/2023 |
2.0.0-preview1 | 121 | 10/13/2023 |
1.1.1 | 5,039 | 1/14/2023 |
1.1.0 | 344 | 1/14/2023 |
1.0.7 | 1,108 | 8/13/2022 |
1.0.6 | 549 | 6/26/2022 |
1.0.5 | 427 | 3/8/2022 |
1.0.5-preview1 | 196 | 3/5/2022 |
1.0.4 | 227 | 2/26/2022 |
1.0.3 | 202 | 2/26/2022 |
1.0.2 | 229 | 2/14/2022 |
1.0.1 | 333 | 10/23/2021 |
1.0.0 | 344 | 6/17/2021 |
1.0.0-build | 211 | 8/13/2022 |