Clear the navigation stack with MvvmCross 6.2.1 and Xamarin.Forms
Asked Answered
T

1

5

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?

Tabbie answered 5/11, 2018 at 9:23 Comment(0)
F
6

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.

Ferrite answered 5/11, 2018 at 13:16 Comment(2)
Perfect! That's just what I needed. Is there also a way to specify this at runtime, as well as 'statically' as an attribute on the page?Tabbie
Good to hear! I don't think its possible to do this at runtime (I checked the source code for you and it doesn't seem to be in there).Ferrite

© 2022 - 2024 — McMap. All rights reserved.