NavigationService.GoBack 方法

定义

导航到后退导航历史记录中的最新条目(如果有)。Navigates to the most recent entry in back navigation history, if there is one.

public:
 void GoBack();
public void GoBack ();
member this.GoBack : unit -> unit
Public Sub GoBack ()

例外

在调用 GoBack() 时后退导航历史记录中没有条目。GoBack() is called when there are no entries in back navigation history.

示例

下面的示例导航到后退导航历史记录中的最新条目(如果有)。The following example navigates to the most recent entry in back navigation history, if one exists.

void backButton_Click(object sender, RoutedEventArgs e)
{
    if (this.NavigationService.CanGoBack)
    {
        this.NavigationService.GoBack();
    }
}
Private Sub backButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If Me.NavigationService.CanGoBack Then
        Me.NavigationService.GoBack()
    End If
End Sub

注解

在调用 GoBack之前,可以检查 CanGoBack 属性,以确定后退导航历史记录中是否存在条目。Before calling GoBack, the CanGoBack property can be inspected to determine whether there are entries in back navigation history.

适用于

另请参阅