CommandBindingCollection::Add Method (CommandBinding^)
.NET Framework (current version)
Adds the specified CommandBinding to this CommandBindingCollection.
Assembly: PresentationCore (in PresentationCore.dll)
Parameters
- commandBinding
-
Type:
System.Windows.Input::CommandBinding^
The binding to add to the collection.
Return Value
Type: System::Int320, if the operation was successful (note that this is not the index of the added item).
| Exception | Condition |
|---|---|
| NotSupportedException | commandBinding is null. |
The following example creates a CommandBinding and adds it to the CommandBindingCollection of a Window.
<Window x:Class="SDKSamples.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:custom="clr-namespace:SDKSamples" Height="600" Width="800" > <Window.CommandBindings> <CommandBinding Command="{x:Static custom:Window1.CustomRoutedCommand}" Executed="ExecutedCustomCommand" CanExecute="CanExecuteCustomCommand" /> </Window.CommandBindings>
.NET Framework
Available since 3.0
Available since 3.0
Show: