Back to Devexpress

NavigationFrame.GoForward() Method

wpf-devexpress-dot-xpf-dot-windowsui-dot-navigationframe-2c195bc6.md

latest4.2 KB
Original Source

NavigationFrame.GoForward() Method

Navigates forward to the previously selected screen (view).

Namespace : DevExpress.Xpf.WindowsUI

Assembly : DevExpress.Xpf.Controls.v25.2.dll

NuGet Package : DevExpress.Wpf.Controls

Declaration

csharp
public void GoForward()
vb
Public Sub GoForward

Remarks

The GoForward method will undo navigation performed via the Back button or the NavigationFrame.GoBack method. This method will have an effect only if the NavigationFrame has navigated back from the current view at least once. You can use the NavigationFrame.CanGoForward property to get whether the GoForward method is available. See the Navigation topic for more info.

You can also navigate back to the previously viewed screen via the NavigationFrame.GoBack method. Its current availability can also be checked via the NavigationFrame.CanGoBack property.

The following example demonstrates how to use the GoForward and NavigationFrame.GoBack methods, called by 2 corresponding NavigationButtons. The custom checkBackForwardState methods checks whether navigation buttons are available each time the NavigationFrame.Navigated event occurs.

xaml
<dxwui:NavigationFrame x:Name="frame1" Source="MainView" AnimationType="SlideHorizontal" Navigated="frame1_Navigated"/>
. . .
<dxwui:NavigationButton x:Name="cmdForward" Click="cmdForward_Click" Content="Forward"/>
<dxwui:NavigationButton x:Name="cmdBack" Click="cmdBack_Click" Content="Back"/>
csharp
public MainWindow() {
    InitializeComponent();
    checkButtonsState();
    . . .
}

private void cmdForward_Click(object sender, RoutedEventArgs e) {
    frame1.GoForward();
}

private void cmdBack_Click(object sender, RoutedEventArgs e) {
    frame1.GoBack();
}

private void checkButtonsState() {
    cmdForward.IsEnabled = frame1.CanGoForward;
    cmdBack.IsEnabled = frame1.CanGoBack;
}

private void frame1_Navigated(object sender, DevExpress.Xpf.WindowsUI.Navigation.NavigationEventArgs e) {
    checkButtonsState();
}
vb
Public Sub MainWindow()
    InitializeComponent()
    checkButtonsState()
    . . .
End Sub

Private Sub cmdForward_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    frame1.GoForward()
End Sub

Private Sub cmdBack_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    frame1.GoBack()
End Sub

Private Sub checkButtonsState()
    cmdForward.IsEnabled = frame1.CanGoForward
    cmdBack.IsEnabled = frame1.CanGoBack
End Sub

Private Sub frame1_Navigated(ByVal sender As Object, ByVal e As DevExpress.Xpf.WindowsUI.Navigation.NavigationEventArgs)
    checkButtonsState()
End Sub

The animation below illustrates the result.

See Also

CanGoForward

GoBack

CanGoBack

Navigation

NavigationFrame Class

NavigationFrame Members

DevExpress.Xpf.WindowsUI Namespace