When a page moves in silverlight, you can override this method.
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); }
NavigationEventArgs has a NavigationEventArgs enumeration, which is defined as
public enum NavigationMode { New = 0, Back = 1, Forward = 2, Refresh = 3, }
But calling e.NavigationMode always throws NotImplementedException
Is there a way in silverlight to detect that a page is moving because the user presses the browser button forward / backward.
What I'm trying to achieve is some kind of state that can be saved when the user clicks the back button.
For example, suppose you have a client page that displays a list of clients in a datagrid. The user can select a customer, and there is a detailed view that shows all the orders for this customer. Now in the order item you can click the hyperlink link, which will lead you to the delivery history of the order, which is a separate page. When the user clicks the "Back" button, I want to return to the clients page and automatically select the client that he was viewing. Is this even possible?
I also tried fragment navigation function
NavigationService.Navigate(new Uri("#currentcustomerid=" + customer.Id.ToString(), UriKind.Relative));
when the customerโs choice changes, but it adds too many elements to the story when the user clicks on different customers on the clientโs page.
EDIT
There is also a method that you can override
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { }
which is the same as handling the NavigationService.Navigating event, as stated in the BugFinder response. In this method, e.NavigationMode always returns New when you click the Back or Forward button. The only time this method returns Back is when you explicitly call NavigationService.GoBack()