Prism.DryIoc.Maui
8.1.191-beta
Prefix Reserved
See the version list below for details.
dotnet add package Prism.DryIoc.Maui --version 8.1.191-beta
NuGet\Install-Package Prism.DryIoc.Maui -Version 8.1.191-beta
<PackageReference Include="Prism.DryIoc.Maui" Version="8.1.191-beta" />
paket add Prism.DryIoc.Maui --version 8.1.191-beta
#r "nuget: Prism.DryIoc.Maui, 8.1.191-beta"
// Install Prism.DryIoc.Maui as a Cake Addin #addin nuget:?package=Prism.DryIoc.Maui&version=8.1.191-beta&prerelease // Install Prism.DryIoc.Maui as a Cake Tool #tool nuget:?package=Prism.DryIoc.Maui&version=8.1.191-beta&prerelease
Prism.Maui
Prism for .NET MAUI is more than simply a port of Prism for Xamarin.Forms. Many of the features remain largely untouched, however the codebase has been written specifically for MAUI. For existing Prism platforms, PrismApplication is responsible for a lot of service registration. Maui presents a very different paradigm to the app startup process as it uses the AppHostBuilder pattern that you may be familiar with from AspNetCore and other .NET Core applications. Due to the fact that services are registered as part of the MauiAppBuilder bootstrapping, the application bootstrapping that you would typically find as part of the PrismApplication is now instead part of PrismAppBuilder.
As part of this rewrite, some attention to making it easier for legacy Xamarin.Forms apps to be ported to MAUI has been given. In general however, this has been written with specific attention to the updated application initialization patterns that we see with .NET MAUI.
Support
Please help support Prism and Prism.Maui by becoming a GitHub Sponsor. The work on Prism.Maui is NOT funded by any entity and is done entirely in my spare time. Your financial contributions help support my efforts to provide the best possible experience for the community.
Using Prism.Maui
To help follow MAUI's App Builder pattern we have introduced the UsePrism<TApp>
extension on the MauiAppBuilder
. This will create a PrismAppBuilder
which gives you specific access to various methods you may want for initializing your application.
// OOB Maui Application
MauiApp.CreateBuilder()
.UseMauiApp<App>();
// Prism.Maui
MauiApp.CreateBuilder()
.UsePrismApp<App>();
Some of the methods available on the PrismAppBuilder
are going to seem a bit familiar for developers coming from Prism for Xamarin.Forms such as:
MauiApp.CreateBuilder()
.UsePrismApp<App>()
.RegisterServices(container => {
container.Register<ISomeService, SomeImplementation>();
container.RegisterForNavigation<ViewA, ViewAViewModel>();
})
.ConfigureModuleCatalog(catalog => {
catalog.AddModule<ModuleA>();
});
.OnInitialized(() => {
// Do some initializations here
});
You will find that this includes useful extensions that consider that you are wiring up these initializations as part of the App Builder. A common case would be where you may have used the container in PrismApplication in the past, you now have an overload that provides the use of the Container.
MauiApp.CreateBuilder()
.UsePrismApp<App>()
.OnInitialized(container => {
var foo = container.Resolve<IFoo>();
// Do some initializations here
});
The PrismAppBuilder
additionally provides some new things to make your life easier.
MauiApp.CreateBuilder()
.UsePrismApp<App>()
.OnAppStart(async navigationService =>
{
var result = await navigationService.NavigateAsync("MainPage/NavigationPage/ViewA");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
});
Microsoft Extensions Support
To help make it even easier we have added some special extensions to the PrismAppBuilder
that will make it easier to use Microsoft Extensions. This includes the ConfigureLogging
method to make it easier to setup your logging while still using the PrismAppBuilder
. For those who prefer to use IServiceCollection
to manage their registrations, you can additionally use the ConfigureServices
extension and bypass the normal Prism RegisterServices
method.
MauiApp.CreateBuilder()
.UsePrismApp<App>()
.ConfigureServices(services => {
services.AddSingleton<IFoo, Foo>();
services.RegisterForNavigation<ViewA, ViewAViewModel>();
});
Upgrading from Prism.Forms
PrismApplication is largely obsolete for Prism.Maui. The PrismAppBuilder does not have an explicit requirement on it. To make it easier on those who are upgrading, we do have legacy support methods to make updating your existing apps a little easier. This includes a RegisterTypes
& OnInitialized
method which will get called during the app initialization. It is recommended however that you migrate this code to your App Builder.
Navigation Builders
Creating a complex navigation stack via a URI can be intimidating for some. For others it can pose a challenge as they require a dynamically built navigation stack. And still other developers have often requested a ViewModel first approach to navigation in Prism. The NavigationBuilder is a great way to help solve these various problems. The NavigationBuilder can be created using an extension on the INavigationService. There is no way to clear the NavigationBuilder, so you should NOT attempt to store this as a property on your ViewModel, and you should instead create a new instance whenever you need to navigate. The samples below are meant to show you some of what is possible. It is not in any way meant as guidance for creating a navigation stack using the most completely random approach possible. Pick a standard approach and follow it. The Builders are meant to expose an API that is easy to use and can help people with different preferences for how to build their navigation stack.
// Shown with option OnError callback
navigationService.CreateBuilder()
.AddNavigationSegment("MainPage")
.AddNavigationPage()
.AddNavigationSegment<ViewAViewModel>()
.AddNavigationSegment("ViewB")
.Navigate(HandleNavigationError);
// This returns the INavigationResult...
// Also available with overloads to provide OnSuccess & OnError callbacks
navigationService.CreateBuilder()
.AddTabbedSegment(b =>
{
b.CreateTab(t => t.AddNavigationSegment<ViewAViewModel>())
.CreateTab("ViewB")
.CreateTab(t => t.AddNavigationPage().AddNavigationSegment<ViewCViewModel>())
.SelectTab<ViewBViewModel>();
})
.NavigateAsync();
It's also important to note that the builders will make some attempt to stop you from breaking the MVVM pattern and you will get an exception if you attempt to do:
navigationService.CreateBuilder()
.AddNavigationSegment<ViewA>()
.Navigate();
NOTE
Prism.Maui is currently a Beta. Any preview build is largely meant to solicit additional developer feedback. APIs will likely change and break prior to being merged into the Prism repo and released as a fully official build.
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. |
-
net6.0
- DryIoc.dll (>= 5.1.0)
- Microsoft.Maui.Dependencies (>= 6.0.312)
- Microsoft.Maui.Extensions (>= 6.0.312)
- Prism.Maui (>= 8.1.191-beta)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Prism.DryIoc.Maui:
Package | Downloads |
---|---|
MvvmCrud.Maui.Prism
MvvmCrud helps your Maui app to standardize operations of creating, updating, deletion and display data, from REST API. |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on Prism.DryIoc.Maui:
Repository | Stars |
---|---|
shinyorg/shiny
.NET Framework for Backgrounding & Device Hardware Services (iOS, Android, & Catalyst)
|
|
egvijayanand/dotnet-maui-samples
.NET MAUI Samples
|
|
muak/AiForms.Maui.SettingsView
SettingsView for .NET MAUI
|
|
Respawnsive/Apizr
Refit based web api client management, but resilient (retry, connectivity, cache, auth, log, priority, etc...)
|
Version | Downloads | Last updated | |
---|---|---|---|
9.0.537 | 18,393 | 8/20/2024 | |
9.0.401-pre | 33,160 | 2/14/2024 | |
9.0.271-pre | 21,378 | 10/8/2023 | |
8.1.273-pre | 49,526 | 8/14/2022 | |
8.1.254-beta | 2,767 | 7/14/2022 | |
8.1.228-beta | 1,493 | 6/14/2022 | |
8.1.191-beta | 10,385 | 5/31/2022 | |
8.1.27-alpha | 544 | 5/28/2021 | |
8.1.16-alpha | 266 | 5/25/2021 |