How to: Navigate Forward Through Navigation History
This example illustrates how to navigate to entries in forward navigation history.
Example
Code that is running from content that is hosted in a NavigationWindow, Frame use NavigationService, or Windows Internet Explorer can navigate forward through navigation history, one entry at a time.
Navigating forward one entry requires first checking that there are entries in forward navigation history, by inspecting the CanGoForward property, before navigating forward one entry, by calling the GoForward method. This is illustrated in the following example:
void navigateForwardButton_Click(object sender, RoutedEventArgs e)
{
// Navigate forward one page from this page, if there is an entry
// in forward navigation history
if (this.NavigationService.CanGoForward)
{
this.NavigationService.GoForward();
}
else
{
MessageBox.Show("No entries in forward navigation history.");
}
}
CanGoForward and GoForward are implemented by NavigationWindow, Frame, and NavigationService.
Note: |
---|
If you call GoForward, and there are no entries in forward navigation history, an InvalidOperationException is raised. |