How would one remove all the forward entries in a navigation service?
I tried this but it is crashing.
while (NavigationService.CanGoForward) NavigationService.RemoveBackEntry();
I know "RemoveBackEntry()" seems odd but there is no RemoveForwardEntry() method.
Any ideas?
Thanks, Kohan
Edit 1: Im a little closer, i can access the forward stack, and even output each item in there but i can not seem to work out how to remove the entries. None of the properties or methods on _frame.ForwardStack or j give any insight into how to remove these entries.
Window mainWindow = Application.Current.MainWindow;
Frame _frame = (Frame)mainWindow.FindName("mainFrame");
foreach (JournalEntry j in _frame.ForwardStack)
{
MessageBox.Show(j.Name);
}
I read into the wpf navigation a little more and if you can get to the instance of NavigationWindow for your application there is a property called ForwardStack that holds the list of forward navigation pages. You should be able to add or remove pages from there.
I have not tried this myself as I do not have a project to test this on right now so let me know if this works as I would like to try this myself in the future.
See msdn link for full member listing: http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationwindow_members.aspx
Well, it's never too late for an answer !
The following piece of code will simply disable forward navigation:
Currently it is for the Frame.Navigating event but it should apply for
Application
as well asNavigationWindow
(did not test though).EDIT:
Here is a
Behavior
for aFrame
:If you renavigate to the current page after you go backwards you should lose all of the forward data just like you would in a web browser or in windows explorer.
If you don't want the refresh to show in the back list you can then remove the last entry from the back list.