How do I clear the Navigation stack?

后端 未结 5 1275
无人共我
无人共我 2021-02-18 18:03

I have problem for Navigation in my app. I use xamarin.forms how can clean my navigation stack. No use Pop and push. Can I see my full navigation stack ?

5条回答
  •  忘掉有多难
    2021-02-18 18:09

    In the latest version of Xamarin.Forms you can see your navigation stack using

    Navigation.NavigationStack
    

    therefore you could use a

    var existingPages = Navigation.NavigationStack.ToList();
    foreach(var page in existingPages)
    {
        Navigation.RemovePage(page);
    }
    

    This code would have to go into your code behind of a Navigation Page or something that implements INavigation.

    More information Xamarin.Forms.INavigation Members

提交回复
热议问题