NavigatingCancelEventArgs Class

Provides data for the Navigating event.

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

public class NavigatingCancelEventArgs : CancelEventArgs
You cannot directly create an instance of this class in XAML.

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:

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 was made, and if one was, how 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.Object
  System.EventArgs
    System.ComponentModel.CancelEventArgs
      System.Windows.Navigation.NavigatingCancelEventArgs

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft