NavigatingCancelEventArgs Class

 

Provides data for the Navigating event.

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

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

public class NavigatingCancelEventArgs : CancelEventArgs

NameDescription
System_CAPS_pubpropertyCancel

Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.)

System_CAPS_pubpropertyContent

Gets a reference to the content object that is being navigated to.

System_CAPS_pubpropertyContentStateToSave

Gets and sets the CustomContentState object that is associated with the back navigation history entry for the page being navigated from.

System_CAPS_pubpropertyExtraData

Gets the optional data Object that was passed when navigation started.

System_CAPS_pubpropertyIsNavigationInitiator

Indicates whether the navigator (NavigationWindow, Frame) that is specified by Navigator is servicing this navigation, or whether a parent navigator is doing so.

System_CAPS_pubpropertyNavigationMode

Gets a NavigationMode value that indicates the type of navigation that is occurring.

System_CAPS_pubpropertyNavigator

The navigator that raised this event.

System_CAPS_pubpropertyTargetContentState

Gets the CustomContentState object that is to be applied to the content being navigated to.

System_CAPS_pubpropertyUri

Gets the uniform resource identifier (URI) for the content being navigated to.

System_CAPS_pubpropertyWebRequest

Gets the WebRequest object that is used to request the specified content.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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
Available since 3.0
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0

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

Return to top
Show: