CanExecuteRoutedEventHandler CanExecuteRoutedEventHandler CanExecuteRoutedEventHandler CanExecuteRoutedEventHandler Delegate

Definition

Represents the method that will handle the CanExecute event.

public delegate void CanExecuteRoutedEventHandler(System::Object ^ sender, CanExecuteRoutedEventArgs ^ e);
public delegate void CanExecuteRoutedEventHandler(object sender, CanExecuteRoutedEventArgs e);
type CanExecuteRoutedEventHandler = delegate of obj * CanExecuteRoutedEventArgs -> unit
Public Delegate Sub CanExecuteRoutedEventHandler(sender As Object, e As CanExecuteRoutedEventArgs)

Parameters

sender
Object Object Object Object

The command target that is invoking the handler.

Inheritance
CanExecuteRoutedEventHandlerCanExecuteRoutedEventHandlerCanExecuteRoutedEventHandlerCanExecuteRoutedEventHandler

Examples

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

void OpenCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    e.CanExecute = true;
}
Private Sub OpenCmdCanExecute(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
    e.CanExecute = True
End Sub

Remarks

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.

Extension Methods

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

Gets an object that represents the method represented by the specified delegate.

Applies to

See also