Compartir a través de


Cómo: Navegar hacia delante por el historial de navegación

En este ejemplo se muestra cómo navegar hacia delante en las entradas del historial de navegación.

Ejemplo

Puede navegar hacia delante mediante el historial de navegación (de entrada en entrada) por el código que se está ejecutando desde el contenido que se hospeda en NavigationWindow, Frame, NavigationService o Windows Internet Explorer.

Para navegar hacia delante a la siguiente entrada es preciso comprobar primero que haya entradas subsiguientes en el historial de navegación inspeccionando la propiedad CanGoForward, antes de navegar a la entrada siguiente llamando al método GoForward. Esto se muestra en el siguiente ejemplo:

        Private Sub navigateForwardButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            ' Navigate forward one page from this page, if there is an entry
            ' in forward navigation history
            If Me.NavigationService.CanGoForward Then
                Me.NavigationService.GoForward()
            Else
                MessageBox.Show("No entries in forward navigation history.")
            End If
        End Sub
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 y GoForward se implementan mediante NavigationWindow, Frame y NavigationService.

NotaNota

Si llama a GoForward y no hay ninguna entrada hacia delante en el historial de navegación, se inicia una excepción InvalidOperationException.