NavigatingCancelEventArgs Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
These event arguments contain information about the navigation that was requested, and are passed to handlers of the Navigating event, which is implemented by the following:
NavigatingCancelEventArgs encapsulates the following details of the navigation request:
-
Navigation Initiation: NavigationMode, Navigator, IsNavigationInitiator.
-
Navigation Request: WebRequest.
-
Navigation State: ExtraData, ContentStateToSave, TargetContentState.
This information allows you to both evaluate the nature of the navigation request, and view and update specified request details before navigation occurs.
Based on the navigation request information provided by NavigatingCancelEventArgs, or based on application-specific state or code, you can completely prevent navigation by setting the Cancel property to true (by default, Cancel is false).
The following example shows how to handle Navigating to detect whether a request to refresh static content has been made and, if so, to cancel the request.
Navigating.
void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e) { // Don't allow refreshing of a static page if ((e.NavigationMode == NavigationMode.Refresh) && (e.Uri.OriginalString == "StaticPage.xaml")) { e.Cancel = true; } }
System.EventArgs
System.ComponentModel.CancelEventArgs
System.Windows.Navigation.NavigatingCancelEventArgs
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.