Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CanExecuteRoutedEventHandler Delegate

Represents the method that will handle the CanExecute event.

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

public delegate void CanExecuteRoutedEventHandler(
	Object sender,
	CanExecuteRoutedEventArgs e
)

Parameters

sender
Type: System.Object

The command target that is invoking the handler.

e
Type: System.Windows.Input.CanExecuteRoutedEventArgs

The event data.

The CanExecuteRoutedEventHandler determines if the command associated with the event source is able to execute on the command target. If the command has a command source that specifies a target, then the target information can be obtained through sender. If the CommandTarget is not set, the element with keyboard focus is the target, and can also be obtained through sender. If it is determined that the command can execute on the target, then the CanExecuteRoutedEventArgs.CanExecute property should be set to true; otherwise, set it to false.

You do not need to rely on event data to determine the command, source, and target. You can limit the usage of the handler to known possible command invocations, although this is more difficult to accomplish if your command structure relies extensively on the command routing to execute the same command on successive potential targets in an event route.

The following example shows a CanExecuteRoutedEventHandler that sets CanExecute to true.

void OpenCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    e.CanExecute = true;
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Show:
© 2014 Microsoft