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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.Maui.LifecycleHelper" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Plugin.Maui.LifecycleHelper --version 1.0.0                
#r "nuget: Plugin.Maui.LifecycleHelper, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

API Usage

Plugin.Maui.LifecycleHelper provides the LifecycleManager class that allows for the modification of Windows. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 138 5/4/2024