Forum Xamarin.Forms

Pulling out your hair because of no lifecycle concept in Xamarin.Forms?

I did for a long time so I came up with this package that may be useful to you:

Documentation and sources:
https://github.com/Tommigun1980/Xamarin.Forms.ExtendedLifecycleContentPage

Nuget package:
https://www.nuget.org/packages/Xamarin.Forms.ExtendedLifecycleContentPage/

I hope someone will find it useful.

Posts

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    You could try to add this to Xamarin community toolkit
  • JohnHJohnH GBMember ✭✭✭✭✭
    I’ve been overriding ParentSet and checking if parent is null or not to detect pushed and popped from a stack, I haven’t seen a situation where that doesn’t work.
  • TommigunTommigun Member ✭✭
    edited August 2020

    @JohnH said:
    I’ve been overriding ParentSet and checking if parent is null or not to detect pushed and popped from a stack, I haven’t seen a situation where that doesn’t work.

    Hi. I'll verify but I don't think it's the same thing. What happens if you say push a page to a modal navigation stack, then push two more pages, then pop one and then dismiss the stack?

    I invoke NavigationPushed on the first page, NavigationPushed on the second page, NavigationPushed on the third page, NavigationPopped on the third page on backwards navigation, and then NavigationPopped on all pages when the stack is dismissed.

    Would the calls be the same with ParentSet?

  • JohnHJohnH GBMember ✭✭✭✭✭

    In my experience yes, ParentSet is called when the page is pushed (and the parent is set), and then again when popped (with parent set to null). But if you are geared up to test that easily then please do let us know! o:)

  • TommigunTommigun Member ✭✭

    @JohnH said:
    In my experience yes, ParentSet is called when the page is pushed (and the parent is set), and then again when popped (with parent set to null). But if you are geared up to test that easily then please do let us know! o:)

    Thanks! I will definitely test that and let you know -- if it works 100% the same in all cases that'd be great.

Sign In or Register to comment.