Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines an object that knows how to invoke a command.
public interface class ICommandSource
public interface ICommandSource
type ICommandSource = interface
Public Interface ICommandSource
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 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.
Gets the command that will be executed when the command source is invoked.
Represents a user defined data value that can be passed to the command when it is executed.
The object that the command is being executed on.