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
/** @delegate */
public delegate void CanExecuteRoutedEventHandler (
	Object sender, 
	CanExecuteRoutedEventArgs e
In XAML, you can use delegates but you cannot define your own.



The source of the event.


The event data.

The CanExecuteRoutedEventHandler determines if the command associated with the event is able to execute on the command target. The command target is either the target set by the ICommandSource or, if the CommandTarget is not set, the element with keyboard focus. If it is determined that the command can execute on the target, then CanExecute should be set to true; otherwise, set it to false.

When you create a CanExecuteRoutedEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Events and Delegates.

The following shows a CanExecuteRoutedEventHandler which sets CanExecute to true.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions