CanExecuteRoutedEventArgs Class
Collapse the table of content
Expand the table of content

CanExecuteRoutedEventArgs Class


Provides data for the CanExecute and PreviewCanExecute routed events.

Namespace:   System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)


public sealed class CanExecuteRoutedEventArgs : RoutedEventArgs


Gets or sets a value that indicates whether the RoutedCommand associated with this event can be executed on the command target.


Gets the command associated with this event.


Determines whether the input routed event that invoked the command should continue to route through the element tree.


Gets or sets a value that indicates the present state of the event handling for a as it travels the route. (Inherited from RoutedEventArgs.)GTMT


Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.(Inherited from RoutedEventArgs.)


Gets the command specific data.


Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. (Inherited from RoutedEventArgs.)


Gets or sets a reference to the object that raised the event. (Inherited from RoutedEventArgs.)


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


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


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


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

Typically, a command source, such a MenuItem, will call the CanExecute method on a RoutedCommand to determine if the command can or cannot execute on the current command target. If CanExecute is set to false from an event handler, the command source will disable itself. For example, if a MenuItem is acting as the command source for a command and the command cannot execute on the current command target, then the MenuItem will gray itself out.

The CanExecuteChanged event notifies a command source when the ability of a command to execute may have changed.

The follow example creates a CanExecuteRoutedEventHandler that returns true only if the command target is a control. First, Source is cast to a Control. If Source is a Control, CanExecute is set to true; otherwise, it is set to false.

.NET Framework
Available since 3.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
© 2015 Microsoft