CommandBindingCollection.Add(CommandBinding) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Adiciona o especificado CommandBinding a este 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
Parâmetros
- commandBinding
- CommandBinding
A encadernação para adicionar à coleção.
Devoluções
0, se a operação tiver sido bem-sucedida (note-se que este não é o índice do item adicionado).
Exceções
commandBinding é null.
Exemplos
O exemplo seguinte cria um CommandBinding e adiciona-o ao CommandBindingCollection de um 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)