tags:

views:

199

answers:

3

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);
        }
A: 

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.

scptre
I did wonder that, i didn't want there to be a back entry added for the current page. I guess the best way is to try it.
Kohan
I am having problems with this solution, i can not load the current page i can only load a new instance of this page but then as i worried it gets added to the journal stack.
Kohan
+1  A: 

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

scptre
Made a little progress but not quite there, see Edit 1. Any ideas?
Kohan
A: 

Hello,

I cannot remove back entries from IE, that belongs to another web site. For example user starts IE with its home page, then types the address of my WPF app, and my app removes all entries (at least I hope), but home page is still there. When user accidentally hit the backspace key, it navigates back to home page...

I am doing some thing wrong ?

Dogu Tumerdem

dogu tumerdem
This is an old question of mine. What you are doing is asking a new question, not answering mine. I suggest making a new Question to get a response to your problem. Welcome to SO.
Kohan