9

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?

Shahriar
  • 939
  • 1
  • 14
  • 36

2 Answers2

15

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();
Igor Ralic
  • 14,975
  • 4
  • 43
  • 51
0

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);
}
El0din
  • 3,208
  • 3
  • 20
  • 31