Clear Back Stack Navigation Windows 10

谁说胖子不能爱 提交于 2019-12-06 22:12:24

问题


I want to Clear my Navigation Back Stack History ...

I tried to use this.NavigationService.RemoveBackEntry(); but It didn't work.

How could I do this in Windows 10?


回答1:


If you're in page code behind, have you tried doing:

this.Frame.BackStack.Clear();

or if you're somewhere else (like a ViewModel), have you tried:

var frame = Window.Current.Content as Frame;
frame.BackStack.Clear();



回答2:


In the code behind, you can try this:

protected override void OnNavigatedFrom(NavigationEventArgs e){
  if (this.GetType().HasRegionAttribute()){
        base.PopFromBackStackTo(typeof(LastViewModel));
  }    
  base.OnNavigatedFrom(e);
}


来源:https://stackoverflow.com/questions/31886251/clear-back-stack-navigation-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!