Como: Navegar Para Trás no Histórico de Navegação
This example illustrates how to navigate to entries in back navigation history.
Exemplo
Code that is running from content that is hosted in a NavigationWindow, Frame use NavigationService, or Windows Internet Explorer can navigate back through navigation history, one entry at a time.
Navigating back one entry requires first checking that there are entries in back navigation history, by inspecting the CanGoBack property, before navigating back one entry, by calling the GoBack method. This is illustrated in the following example:
Private Sub navigateBackButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
' Navigate back one page from this page, if there is an entry
' in back navigation history
If Me.NavigationService.CanGoBack Then
Me.NavigationService.GoBack()
Else
MessageBox.Show("No entries in back navigation history.")
End If
End Sub
void navigateBackButton_Click(object sender, RoutedEventArgs e)
{
// Navigate back one page from this page, if there is an entry
// in back navigation history
if (this.NavigationService.CanGoBack)
{
this.NavigationService.GoBack();
}
else
{
MessageBox.Show("No entries in back navigation history.");
}
}
CanGoBack and GoBack are implemented by NavigationWindow, Frame, and NavigationService.
Observação
If you call GoBack, and there are no entries in back navigation history, an InvalidOperationException is raised.