Skip to content

Helps MAUI developers implement lifecycle triggers in Pages of Shell, NavigationPage or TabbedPage.

License

Notifications You must be signed in to change notification settings

Zaibatsu89/Plugin.Maui.LifecycleHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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! <3

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

About

Helps MAUI developers implement lifecycle triggers in Pages of Shell, NavigationPage or TabbedPage.

Topics

Resources

License

Stars

Watchers

Forks

Languages