Plugin.Maui.LifecycleHelper
1.0.0
dotnet add package Plugin.Maui.LifecycleHelper --version 1.0.0
NuGet\Install-Package Plugin.Maui.LifecycleHelper -Version 1.0.0
<PackageReference Include="Plugin.Maui.LifecycleHelper" Version="1.0.0" />
paket add Plugin.Maui.LifecycleHelper --version 1.0.0
#r "nuget: Plugin.Maui.LifecycleHelper, 1.0.0"
// Install Plugin.Maui.LifecycleHelper as a Cake Addin #addin nuget:?package=Plugin.Maui.LifecycleHelper&version=1.0.0 // Install Plugin.Maui.LifecycleHelper as a Cake Tool #tool nuget:?package=Plugin.Maui.LifecycleHelper&version=1.0.0
Plugin.Maui.LifecycleHelper
Plugin.Maui.LifecycleHelper
provides the ability to implement lifecycle triggers in Pages of Shell, NavigationPage or TabbedPage inside a .NET MAUI application. It is the evolution of Zaibatsu89 maui-lifecycle-helper.
Getting Started
- Available on NuGet: https://www.nuget.org/packages/Plugin.Maui.LifecycleHelper
API Usage
Plugin.Maui.LifecycleHelper
provides the LifecycleManager
class that allows for the modification of Window
s. The LifecycleManager
can be used with or without dependency injection.
LifecycleManager
There are two different ways in which you can interact with the LifecycleManager
implementation provided by this plugin, they are:
Dependency Injection
You will first need to register the LifecycleManager
with the MauiAppBuilder
based on the following example:
builder.AddLifecycleHelper();
You can then enable your App
class to depend on ILifecycleManager
as per the following example.
public partial class App : Application
{
public App(ILifecycleManager lifecycleManager)
{
this.lifecycleManager = lifecycleManager;
}
protected override Window CreateWindow(IActivationState activationState)
{
Window window = base.CreateWindow(activationState);
lifecycleManager.ModifyWindow(window, MainPage);
return window;
}
}
Straight usage
Alternatively if you want to skip using the dependency injection approach you can use the LifecycleManager.Current
property.
public partial class App : Application
{
protected override Window CreateWindow(IActivationState activationState)
{
Window window = base.CreateWindow(activationState);
LifecycleManager.Current.ModifyWindow(window, MainPage);
return window;
}
}
Now that you know how tu use the LifecycleManager
class, please refer to the following section:
Acknowledgements
This project could not have came to be without these projects and people, thank you! ❤️
Plugin.Maui.Feature template
Basically the template for this plugin. We have been using this in our .NET MAUI projects with much joy and ease, so thank you so much Gerald (and contributors!) for that. Find the original project here where we have based our project on and evolved it from there.
Changelog
- Version 1.0.0
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 132 | 5/4/2024 |