Executes the RoutedCommand on the current command target.
Assembly: PresentationCore (in PresentationCore.dll)
The actual logic that executes the RoutedCommand is not contained in the methods. raises the PreviewExecuted and Executed events, which tunnel and bubble through the element tree looking for an object with a CommandBinding. If a CommandBinding for that RoutedCommand is found, then the ExecutedRoutedEventHandler attached to CommandBinding is called. These handlers supply the programming logic that performs the RoutedCommand.
The PreviewExecuted and Executed events are raised on the CommandTarget. If the CommandTarget is not set on the ICommandSource, the PreviewExecuted and Executed events are raised on the element with keyboard focus.
The following example is from a custom implementation of ICommandSource sample.
this.Command in this example is the Command property on the ICommandSource. If the command is not null, the command is cast to a RoutedCommand. If it is a RoutedCommand, then the method is called passing the CommandTarget and the CommandParameter. If the command is not a RoutedCommand, it is cast to an ICommand and the Execute method is called passing the CommandParameter.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.