-
Notifications
You must be signed in to change notification settings - Fork 12
Home
Maui.Plugins.PageResolver is a super-lightweight package for .NET MAUI projects. It leverages the built-in DI container to resolve pages for you with all their dependencies, including ViewModels and services.
Using PageResolver, you can just use Navigation.PushAsync<MyPage>();
in your code, and the Resolver will push a fully resolved instance of MyPage
onto the navigation stack.
The latest version supports parameters too. If you have a page with a non-default constructor you can pass the parameters it expects too, eg., Navigation.PushAsync<MyPage>(arg1, arg2, ...);
. You don't need to include the ViewModel (or anything registered with the ServiceProvider) as this will be resolved for you.
Use the links on the right to explore the capabilities of the package.
Very. In fact, there are way more lines of text in this wiki than there are lines of code in the package. Unlike MVVM frameworks used in Xamarin.Forms, this package doesn't need to provide its own IoC container or DI implementation. .NET MAUI uses the generic host builder pattern and includes DI out of the box, which PageResolver uses. Apart from the UseAutoDependencies
source generator, PageResolver is just a collection of useful extension methods.
Yes it works with Shell! Shell resolves dependencies for you automatically, so you don't need PageResolver for regular navigation, but it's useful for the UseAutoDependencies
source generator, and also when using modal pages or setting a resolved binding context in XAML.