Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CommandManager Class
Collapse the table of content
Expand the table of content

CommandManager Class

Provides command related utility methods that register CommandBinding and InputBinding objects for class owners and commands, add and remove command event handlers, and provides services for querying the status of a command.

System.Object
  System.Windows.Input.CommandManager

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

public sealed class CommandManager

The CommandManager type exposes the following members.

  NameDescription
Public methodStatic memberAddCanExecuteHandlerAttaches the specified CanExecuteRoutedEventHandler to the specified element.
Public methodStatic memberAddExecutedHandlerAttaches the specified ExecutedRoutedEventHandler to the specified element.
Public methodStatic memberAddPreviewCanExecuteHandlerAttaches the specified CanExecuteRoutedEventHandler to the specified element.
Public methodStatic memberAddPreviewExecutedHandlerAttaches the specified ExecutedRoutedEventHandler to the specified element.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberInvalidateRequerySuggestedForces the CommandManager to raise the RequerySuggested event.
Public methodStatic memberRegisterClassCommandBindingRegisters a CommandBinding with the specified type.
Public methodStatic memberRegisterClassInputBindingRegisters the specified InputBinding with the specified type.
Public methodStatic memberRemoveCanExecuteHandlerDetaches the specified CanExecuteRoutedEventHandler from the specified element.
Public methodStatic memberRemoveExecutedHandlerDetaches the specified ExecutedRoutedEventHandler from the specified element.
Public methodStatic memberRemovePreviewCanExecuteHandlerDetaches the specified CanExecuteRoutedEventHandler from the specified element.
Public methodStatic memberRemovePreviewExecutedHandlerDetaches the specified ExecutedRoutedEventHandler from the specified element.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventStatic memberRequerySuggestedOccurs when the CommandManager detects conditions that might change the ability of a command to execute.
Top

  NameDescription
Public attached eventCanExecuteOccurs when the CanExecute method on the RoutedCommand is called and the PreviewCanExecute event was not handled.
Public attached eventExecutedOccurs when the Execute method on the RoutedCommand is called and the PreviewExecuted event was not handled.
Public attached eventPreviewCanExecuteOccurs when the CanExecute method on the RoutedCommand is called.
Public attached eventPreviewExecutedOccurs when the Execute method on the RoutedCommand is called.
Top

  NameDescription
Public fieldStatic memberCanExecuteEventIdentifies the CanExecute attached event.
Public fieldStatic memberExecutedEventIdentifies the Executed attached event.
Public fieldStatic memberPreviewCanExecuteEventIdentifies the PreviewCanExecute attached event.
Public fieldStatic memberPreviewExecutedEventIdentifies the PreviewExecuted attached event.
Top

The CommandManager is responsible for managing routed commands. For more information about commanding, see Commanding Overview.

Use RegisterClassCommandBinding to register a CommandBinding to a class as opposed to an instance.

Use RegisterClassInputBinding to register an InputBinding to a class as opposed to an instance.

The InvalidateRequerySuggested method forces the CommandManager to raise the RequerySuggested event. The RequerySuggested event informs a command source to query the command it is associated with to determine whether or not the command can execute.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft