ICommandSource.CommandTarget Property

Definition

The object that the command is being executed on.

C#
public System.Windows.IInputElement CommandTarget { get; }

Property Value

The object that the command is being executed on.

Remarks

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.

When used with a RoutedCommand, the command target is the object on which the Executed and CanExecute events are raised. If the CommandTarget property is not set, the element with keyboard focus will be used as the target.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also