ICommandSource Interface
TOC
Collapse the table of content
Expand the table of content

ICommandSource Interface

 

Defines an object that knows how to invoke a command.

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

public interface ICommandSource

NameDescription
System_CAPS_pubpropertyCommand

Gets the command that will be executed when the command source is invoked.

System_CAPS_pubpropertyCommandParameter

Represents a user defined data value that can be passed to the command when it is executed.

System_CAPS_pubpropertyCommandTarget

The object that the command is being executed on.

The command source defines how a command is invoked by that particular object. For example, if a Button is associated with a command, the command is invoked when the Button is clicked.

A command source will normally disable itself if the command it is associated with cannot execute on the current command target. For example, a MenuItem associated with the Paste command will gray itself out when the Paste command cannot execute on the current command target.

Normally, a command source will listen to the CanExecuteChanged event on the command. This informs the command source when conditions change on the command target, such as loss of keyboard focus. The command source can then query the command using the CanExecute method.

Some of the classes in WPF that implement ICommandSource are: ButtonBase, MenuItem, and Hyperlink.

In the Windows Presentation Foundation (WPF) commanding system, the CommandTarget property on a ICommandSource is only applicable when the ICommand is a RoutedCommand. If the CommandTarget is set on a ICommandSource and the corresponding command is not a RoutedCommand, the command target is ignored.

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft