Is there any way to manually remove a history item from the NavigationToolbar? In my current situation, a previously visited location can be deleted by the user while they are not in that location. So I need to remove that item from the history. Is this possible?
Actually, there is a way to manipulate the history. By using the ResetNavigationHistory and InitializeHistory methods you can have complete control over the history. I needed a way to remove a particular item from the history, so I manually created 2 separate lists (one for back history and the other for forward history) from the original history. I simply ignored adding the item I no longer wanted to these new lists. Then I reset the history and initialized it. When using InitializeHistory, you pass it the array for the back history, the array for the forward history, and then the current item (NavigationHistoryItem) that the history is on.
To loop through the existing history, you can use the BackHistory.GetEnumerator() and ForwardHistory.GetEnumerator() and enumerate through the history items without a problem (IEnumerator<NavigationHistoryItem> ienum = navigationBar.ForwardHistory.GetEnumerator()).
Yes, this is definetly required, how could the developers of the NavigationToolbar at the time of writing it, not think having this ability to be useful.
I'll have to result to reflection now, hope you guys don't change the private variables before you implement this functionality.
I don't know that there's any public method exposed that will let you do this. You may be able to use reflection to get at the private BackHistoryInternal or ForwardHistoryInternal property of the NavigationToolbar, which is of type List<NavigationHistoryItem> and then remove the item that way. You should also submit a feature request through Developer Support to provide this functionality.
-Matt