CommandBinding Class

Definition

Associa un oggetto RoutedCommand ai gestori eventi che implementano il comando.Binds a RoutedCommand to the event handlers that implement the command.

public ref class CommandBinding
public class CommandBinding
type CommandBinding = class
Public Class CommandBinding
Inheritance
CommandBinding

Remarks

Un CommandBinding associa un comando al PreviewExecuted/Executed e PreviewCanExecute/eventi CanExecute che implementano e determinano lo stato del comando.A CommandBinding associates a command with the PreviewExecuted/Executed and PreviewCanExecute/CanExecute events which implement and determine the status of the command.

Quando viene chiamato il metodo Execute o CanExecute di un RoutedCommand, nella destinazione del comando vengono generati gli eventi /Executed PreviewExecutedo PreviewCanExecute/CanExecute.When the Execute or CanExecute method of a RoutedCommand is called, the PreviewExecuted/Executed or the PreviewCanExecute/CanExecute events are raised on the command target. Se la destinazione del comando ha un CommandBinding per il comando, vengono chiamati i gestori appropriati.If the command target has a CommandBinding for the command, the appropriate handlers are called. Se la destinazione del comando non dispone di un CommandBinding per il comando, gli eventi vengono instradati attraverso l'albero degli elementi fino a quando non viene trovato un elemento con CommandBinding.If the command target does not have a CommandBinding for the command, the events are routed through the element tree until an element that has a CommandBinding is found.

Un CommandBinding ha un utilizzo limitato con un ICommand che non è un RoutedCommand.A CommandBinding has limited use with an ICommand that is not a RoutedCommand. Questo perché un CommandBinding associa il comando al ExecutedRoutedEventHandler e CanExecuteRoutedEventHandler che restano in ascolto degli eventi indirizzati Executed e CanExecute generati quando vengono chiamati Execute e CanExecute metodo del RoutedCommand.This is because a CommandBinding binds the command to the ExecutedRoutedEventHandler and the CanExecuteRoutedEventHandler which listen to the Executed and CanExecute routed events which are raised when the Execute and CanExecute method of the RoutedCommand are called.

Constructors

CommandBinding()

Inizializza una nuova istanza della classe CommandBinding.Initializes a new instance of the CommandBinding class.

CommandBinding(ICommand)

Inizializza una nuova istanza della classe CommandBinding mediante l'elemento ICommand specificato.Initializes a new instance of the CommandBinding class by using the specified ICommand.

CommandBinding(ICommand, ExecutedRoutedEventHandler)

Inizializza una nuova istanza della classe CommandBinding mediante i gestori eventi ICommand e Executed specificati.Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed event handler.

CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler)

Inizializza una nuova istanza della classe CommandBinding mediante i gestori eventi ICommand, Executed e CanExecute specificati.Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed and CanExecute event handlers.

Properties

Command

Ottiene o imposta l'oggetto ICommand associato a CommandBinding.Gets or sets the ICommand associated with this CommandBinding.

Methods

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Inherited from Object)

Events

CanExecute

Si verifica quando il comando associato a CommandBinding avvia un controllo per determinare se è possibile eseguire il comando sulla destinazione.Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the command target.

Executed

Si verifica quando viene eseguito il comando associato a CommandBinding.Occurs when the command associated with this CommandBinding executes.

PreviewCanExecute

Si verifica quando il comando associato a CommandBinding avvia un controllo per determinare se è possibile eseguire il comando sulla destinazione corrente.Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the current command target.

PreviewExecuted

Si verifica quando viene eseguito il comando associato a CommandBinding.Occurs when the command associated with this CommandBinding executes.

Applies to

See also