NavigationService.NavigationFailed NavigationService.NavigationFailed NavigationService.NavigationFailed NavigationService.NavigationFailed Event

Definition

Occurs when an error occurs while navigating to the requested content.

public:
 event System::Windows::Navigation::NavigationFailedEventHandler ^ NavigationFailed;
public event System.Windows.Navigation.NavigationFailedEventHandler NavigationFailed;
member this.NavigationFailed : System.Windows.Navigation.NavigationFailedEventHandler 
Public Event NavigationFailed As NavigationFailedEventHandler 

Examples

The following example shows how to handle NavigationFailed.

void NavigationService_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
    string msg = string.Format("Navigation to {0} failed: {1}.", e.Uri.OriginalString, e.Exception.Message);
    this.progressStatusBarItem.Content = msg;
}
Private Sub NavigationService_NavigationFailed(ByVal sender As Object, ByVal e As NavigationFailedEventArgs)
    Dim msg As String = String.Format("Navigation to {0} failed: {1}.", e.Uri.OriginalString, e.Exception.Message)
    Me.progressStatusBarItem.Content = msg
End Sub

Remarks

When either a WebException or an IOException is thrown during a navigation, the NavigationFailed event is raised. NavigationFailed is passed a NavigationFailedEventArgs that encapsulates information about both the exception and the details of the navigation that caused the exception.

When an exception results from a failed navigation, and is unhandled, the following events are raised in the order listed:

If a navigator (NavigationWindow, Frame) is hosted by one or more navigators, NavigationFailed is not raised on any of them.

Applies to

See also