清除后台堆栈导航Windows 10

时间:2015-08-07 20:36:54

标签: c# windows-10 windows-10-mobile

我想清除我的导航返回堆栈历史...

我尝试使用this.NavigationService.RemoveBackEntry();,但它没有用。

我如何在Windows 10中执行此操作?

2 个答案:

答案 0 :(得分:14)

如果您的页面代码落后,您是否尝试过:

this.Frame.BackStack.Clear();

或者如果您在其他地方(如ViewModel),您是否尝试过:

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

答案 1 :(得分:0)

在后面的代码中,你可以试试这个:

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