Uredi

Deli z drugimi prek


ICommandSource Interface

Definition

Defines an object that knows how to invoke a command.

public interface class ICommandSource
public interface ICommandSource
type ICommandSource = interface
Public Interface ICommandSource
Derived

Remarks

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.

Properties

Command

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

CommandParameter

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

CommandTarget

The object that the command is being executed on.

Applies to

See also