Search code examples
xamarin.formsnavigationmvvmcross

Clear the navigation stack with MvvmCross 6.2.1 and Xamarin.Forms


We need to clear the navigation stack when navigating to certain pages in our Xamarin.Forms app on Android and iOS.

There's an article by Greg Shackles here which describes how to do it - but this is approaching 4 years old and is for an older version of MvvmCross.

Is there a recommended way to do this with MvvmCross 6.2.1? Or do we still need to extend the Presenters?


Solution

  • This might not be exactly what you're looking for but you can use the NoHistory parameter on the MvxContentPagePresentation attribute.

    Here is an example:

    [MvxContentPagePresentation(NoHistory = true)]
    public class TestPage : MvxContentPage<TestViewModel>
    {
    
    }
    

    (You must put this attribute on the page you're navigating to.)

    This clears the navigation stack on both Android and iOS.