Forum Xamarin.Forms

MVVM Light - Remove Navigation pages from stack

trebor74trebor74 USMember ✭✭
edited February 2018 in Xamarin.Forms

I have simple forms based application which submits an application to a service, upon which I want to clear the navigation stack, so that a new application can be entered. I know this is possible with out of the box Xamarin using Navigation.RemovePage, but no idea how do this within MVVM Lights navigation service framework.
I have the following in the NavigateTo method using parameter as an indicator to clear the stack:

if (parameter == null)
{
    foreach (var pageList in _navigation.Pages)
    {
        //Remove from navigation stack                                   
    }
}   

I was hoping I could fire something from here to clear the stack so that the pages are refreshed.

Thanks

Best Answer

Answers

  • trebor74trebor74 USMember ✭✭

    Thanks. Do you have any examples of this?

  • NMackayNMackay GBInsider, University mod

    Sent you a PM, don't want to post it here as it points to my google drive, I'll post it on my github when I clean it up a bit.

  • trebor74trebor74 USMember ✭✭

    Further to above, using MVVMLight, you can use SimpleIoc.Default.Unregister<ViewModel>(); to completely remove the model, view and bindings. I found just popping from the stack, (using Application.Current.MainPage.Navigation.PopAsync();) didn't clear the model data, just the navigation.

  • CharwakaCharwaka INMember ✭✭✭✭✭

    @NMackay said:
    Sent you a PM, don't want to post it here as it points to my google drive, I'll post it on my github when I clean it up a bit.

    Hi,

    Can you please DM me Same or provide link Thanks

  • NMackayNMackay GBInsider, University mod
    edited December 2018

    @Charwaka said:

    @NMackay said:
    Sent you a PM, don't want to post it here as it points to my google drive, I'll post it on my github when I clean it up a bit.

    Hi,

    Can you please DM me Same or provide link Thanks

    I think this is it on my github page.

    https://github.com/mackayn/MVVM-Light-Sample

    DISCLAIMER: I haven't looked at this for yonks so can't guarantee it'll work with the latest build of Forms.

Sign In or Register to comment.