Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationService remove complete back navigation

Using NavigationService.RemoveBackEntry() I can remove one entry from the navigation stack. Is there a convenient way to remove all back navigation items in my app (scenario: I have a sign-up procedure which consists of multiple pages, and after successful registration I do not want the user to navigate back to the registration steps).

like image 373
qqilihq Avatar asked Sep 12 '13 22:09

qqilihq


People also ask

How does navigation history work in navigation service?

When content is navigated to, NavigationService records the navigation as an entry in navigation history. An entry is added to back navigation history when either a new navigation occurs, by calling the Navigate method, or by navigating to an entry in forward navigation history, by calling GoForward.

How do I remove the most recent entry in navigation history?

Also, the most recent entry in back navigation history can be removed by calling RemoveBackEntry. By default, NavigationService does not store an instance of a content object in navigation history. Instead, NavigationService creates a new instance of the content object each time it is navigated to by using navigation history.

How do I retrieve the back navigation history?

The most recent JournalEntry in back navigation history, if there is one. If two or more navigators ( NavigationWindow, Frame) share the same navigation history, one navigator can use RemoveBackEntry to retrieve the back navigation history entry for a navigation that took place in another navigator.

How does navigationservice store an instance of a content object?

By default, NavigationService does not store an instance of a content object in navigation history. Instead, NavigationService creates a new instance of the content object each time it is navigated to by using navigation history.


2 Answers

It's not that inconvenient to do that with RemoveBackEntry:

while(NavigationService.CanGoBack)
{
    NavigationService.RemoveBackEntry();
}
like image 193
jlahd Avatar answered Sep 24 '22 21:09

jlahd


Or use this, a single line code

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        while (NavigationService.RemoveBackEntry() != null) ;
    }
like image 31
Vivek Maskara Avatar answered Sep 25 '22 21:09

Vivek Maskara