CommandBindingCollection.Add(CommandBinding) 메서드

정의

지정된 CommandBinding 값을 이 CommandBindingCollection에 추가합니다.

public:
 int Add(System::Windows::Input::CommandBinding ^ commandBinding);
public int Add(System.Windows.Input.CommandBinding commandBinding);
member this.Add : System.Windows.Input.CommandBinding -> int
Public Function Add (commandBinding As CommandBinding) As Integer

매개 변수

commandBinding
CommandBinding

컬렉션에 추가할 바인딩입니다.

반품

작업이 성공한 경우 0입니다(추가된 항목의 인덱스가 아님).

예외

commandBinding 가 null입니다.

예제

다음 예제에서는 a를 CommandBinding 만들고 에 추가 CommandBindingCollection 합니다 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>
CommandBinding customCommandBinding = new CommandBinding(
    CustomRoutedCommand, ExecutedCustomCommand, CanExecuteCustomCommand);

// attach CommandBinding to root window
this.CommandBindings.Add(customCommandBinding);
Dim customCommandBinding As New CommandBinding(CustomRoutedCommand, AddressOf ExecutedCustomCommand, AddressOf CanExecuteCustomCommand)

' attach CommandBinding to root window
Me.CommandBindings.Add(customCommandBinding)

적용 대상

추가 정보