共用方式為


NavigationService.NavigationFailed 事件

定義

在巡覽所要求的內容時,如果發生錯誤,就會發生。

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

事件類型

範例

下列範例示範如何處理 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

備註

WebException在導覽期間擲回 或 IOException 時, NavigationFailed 會引發 事件。 NavigationFailed 會傳遞 , NavigationFailedEventArgs 封裝例外狀況的相關資訊,以及造成例外狀況之導覽的詳細資料。

當例外狀況因流覽失敗而未處理時,會依照列出的順序引發下列事件:

如果導覽器 (NavigationWindowFrame) 是由一或多個導覽器裝載, NavigationFailed 則不會在任何導覽器上引發。

適用於

另請參閱