CommandBinding.Command Property
.NET Framework (current version)
Gets or sets the ICommand associated with this CommandBinding.
Assembly: PresentationCore (in PresentationCore.dll)
[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)] public ICommand Command { get; set; }
The following example creates a CommandBinding that maps an ExecutedRoutedEventHandler and a CanExecuteRoutedEventArgs handler to the Open command.
<Window.CommandBindings> <CommandBinding Command="ApplicationCommands.Open" Executed="OpenCmdExecuted" CanExecute="OpenCmdCanExecute"/> </Window.CommandBindings>
// Creating CommandBinding and attaching an Executed and CanExecute handler CommandBinding OpenCmdBinding = new CommandBinding( ApplicationCommands.Open, OpenCmdExecuted, OpenCmdCanExecute); this.CommandBindings.Add(OpenCmdBinding);
The following shows the CanExecuteRoutedEventHandler which sets CanExecute to true.
The following shows the ExecutedRoutedEventHandler which creates a MessageBox when the command is executed.
.NET Framework
Available since 3.0
Available since 3.0
Show: