Giter Club home page Giter Club logo

plugin.maui.lifecyclehelper's Introduction

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

plugin.maui.lifecyclehelper's People

Contributors

zaibatsu89 avatar

Stargazers

BlueSharkPartners avatar

Watchers

 avatar

Forkers

huafangyun

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.