Export (0) Print
Expand All

NavigationService.CanGoBack Property

Gets a value that indicates whether there is at least one entry in the back navigation history.

Namespace:  System.Windows.Navigation
Assembly:  System.Windows.Controls.Navigation (in System.Windows.Controls.Navigation.dll)

public bool CanGoBack { get; }

Property Value

Type: System.Boolean
true if there is at least one entry in the back navigation history; otherwise, false.

The GoBack method throws an InvalidOperationException exception if there are no entries in the back navigation history. To determine whether there is at least one entry in the back navigation history, check the value of the CanGoBack property.

The following example shows buttons within a Silverlight page that allow forward and back navigation. The page uses the NavigationService property of the Page class to access the navigation service used by the hosting frame.


private void BackNavButton_Click(object sender, RoutedEventArgs e)
{
    if (NavigationService.CanGoBack)
    {
        NavigationService.GoBack();
    }
}

private void ForwardNavButton_Click(object sender, RoutedEventArgs e)
{
    if (NavigationService.CanGoForward)
    {
        NavigationService.GoForward();
    }
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft