Windows apps
Collapse the table of content
Expand the table of content
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.

CommandBinding Class

 

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

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

System.Object
  System.Windows.Input.CommandBinding

Public Class CommandBinding

NameDescription
System_CAPS_pubmethodCommandBinding()

Initializes a new instance of the CommandBinding class.

System_CAPS_pubmethodCommandBinding(ICommand)

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

System_CAPS_pubmethodCommandBinding(ICommand, ExecutedRoutedEventHandler)

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

System_CAPS_pubmethodCommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler)

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

NameDescription
System_CAPS_pubpropertyCommand

Gets or sets the ICommand associated with this CommandBinding.

NameDescription
System_CAPS_pubmethodEquals(Object)

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

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_pubmethodGetType()

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

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

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

NameDescription
System_CAPS_pubeventCanExecute

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

System_CAPS_pubeventExecuted

Occurs when the command associated with this CommandBinding executes.

System_CAPS_pubeventPreviewCanExecute

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

System_CAPS_pubeventPreviewExecuted

Occurs when the command associated with this CommandBinding executes.

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 aRoutedCommand. 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.

.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
Show:
© 2016 Microsoft