CommandBinding CommandBinding CommandBinding CommandBinding Class

Definition

Binds a RoutedCommand to the event handlers that implement the command.

public ref class CommandBinding
public class CommandBinding
type CommandBinding = class
Public Class CommandBinding
Inheritance
CommandBindingCommandBindingCommandBindingCommandBinding

Remarks

A CommandBinding associates a command with the PreviewExecuted/Executed and PreviewCanExecute/CanExecute events which implement and determine the status of the command.

When the Execute or CanExecute method of a RoutedCommand is called, the PreviewExecuted/Executed or the PreviewCanExecute/CanExecute events are raised on the command target. If the command target has a CommandBinding for the command, the appropriate handlers are called. If the command target does not have a CommandBinding for the command, the events are routed through the element tree until an element that has a CommandBinding is found.

A CommandBinding has limited use with an ICommand that is not a RoutedCommand. This is because a CommandBinding binds the command to the ExecutedRoutedEventHandler and the CanExecuteRoutedEventHandler which listen to the Executed and CanExecute routed events which are raised when the Execute and CanExecute method of the RoutedCommand are called.

Constructors

CommandBinding() CommandBinding() CommandBinding() CommandBinding()

Initializes a new instance of the CommandBinding class.

CommandBinding(ICommand) CommandBinding(ICommand) CommandBinding(ICommand) CommandBinding(ICommand)

Initializes a new instance of the CommandBinding class by using the specified ICommand.

CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler)

Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed event handler.

CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler)

Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed and CanExecute event handlers.

Properties

Command Command Command Command

Gets or sets the ICommand associated with this CommandBinding.

Events

CanExecute CanExecute CanExecute CanExecute

Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the command target.

Executed Executed Executed Executed

Occurs when the command associated with this CommandBinding executes.

PreviewCanExecute PreviewCanExecute PreviewCanExecute PreviewCanExecute

Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the current command target.

PreviewExecuted PreviewExecuted PreviewExecuted PreviewExecuted

Occurs when the command associated with this CommandBinding executes.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See Also