Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Xamarin Forms + MvvmCross: how to clear the iOS and Android Navigation Stack? (custom presenters)

$
0
0

Hello,

On our iOS and Android apps we would like to clear the Navigation Stack in certain cases.

Searching around the Intertubes, I found a few articles:

http://gregshackles.com/presenters-in-mvvmcross-manipulating-the-back-stack/
http://gregshackles.com/presenters-in-mvvmcross-using-presentation-values/
http://stackoverflow.com/questions/17474865/mvvmcross-navigate-back-multiple-viewmodels-truncate-navigation-stack
http://slodge.blogspot.com/2013/06/presenter-roundup.html
https://gist.github.com/gshackles/5735595
https://github.com/ChristianRuiz/MvvmCross-ControlsNavigation
https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/Fragments/FragmentSample.UI.Droid/Setup.cs
http://stackoverflow.com/questions/22166869/how-to-hint-where-to-show-a-view-in-mvvmcross-with-splitview
http://enginecore.blogspot.com/2013/06/more-dynamic-android-fragments-with.html
https://canbilgin.wordpress.com/tag/mvxformsiospagepresenter/

I have a good idea that I need to do something like this -

var mvxBundle = new MvxBundle(new Dictionary<string, string> { { "NavigationCommand", "StackClear" } });
ShowViewModel<MyViewModel>(presentationBundle: mvxBundle);

And then I need to implement iOS and Android custom presenters that look for the "Clear" command above and clear the navigation stacks.

I'm using the out-of-the-box Xamarin Forms/MvvmCross presenters, here it is for iOS -

protected override IMvxIosViewPresenter CreatePresenter()
{
    Forms.Init();

    var xamarinFormsApp = new MvxFormsApp();

    return new MvxFormsIosPagePresenter(Window, xamarinFormsApp);
}

And here it is for Android -

protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
    var presenter = new MvxFormsDroidPagePresenter();
    Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);

    return presenter;
}

I'm having a hard time properly implementing the custom presenters for iOS and Android.

Does anyone know of a good example or can give me a hint on how to implement custom presenters to clear the iOS and Android navigation stacks in the context of Xamarin Forms + MvvmCross?

Thanks for any help!
@ehuna


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>