Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

NavigatingCancelEventArgs Class

Provides data for the Navigating event.

System.Object
  System.EventArgs
    System.ComponentModel.CancelEventArgs
      System.Windows.Navigation.NavigatingCancelEventArgs

Namespace:  System.Windows.Navigation
Assembly:  PresentationFramework (in PresentationFramework.dll)
public class NavigatingCancelEventArgs : CancelEventArgs

The NavigatingCancelEventArgs type exposes the following members.

  NameDescription
Public propertyCancelGets or sets a value indicating whether the event should be canceled. (Inherited from CancelEventArgs.)
Public propertyContentGets a reference to the content object that is being navigated to.
Public propertyContentStateToSaveGets and sets the CustomContentState object that is associated with the back navigation history entry for the page being navigated from.
Public propertyExtraDataGets the optional data Object that was passed when navigation started.
Public propertyIsNavigationInitiatorIndicates whether the navigator (NavigationWindow, Frame) that is specified by Navigator is servicing this navigation, or whether a parent navigator is doing so.
Public propertyNavigationModeGets a NavigationMode value that indicates the type of navigation that is occurring.
Public propertyNavigatorThe navigator that raised this event.
Public propertyTargetContentStateGets the CustomContentState object that is to be applied to the content being navigated to.
Public propertyUriGets the uniform resource identifier (URI) for the content being navigated to.
Public propertyWebRequestGets the WebRequest object that is used to request the specified content.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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;
    }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.