ICommand ICommand ICommand Interface

Defines the contract for commanding.

.NET This interface appears as System.Windows.Input.ICommand.

Syntax

Declaration

public interface ICommandpublic interface ICommandPublic Interface ICommand

Remarks

When programming with .NET, this interface is hidden and developers should use the System.Windows.Input.ICommand interface.

Note

Older versions of .NET reference documentation (3.0) indicate that the System.Windows.Input.ICommand interface is defined in PresentationCore, which is a Windows Presentation Foundation (WPF) assembly. That is no longer the case, System.Windows.Input.ICommand is defined in the System.ObjectModel assembly, so you don't need to take Windows Presentation Foundation (WPF) dependencies in order to implement ICommand.

Methods summary

Defines the method that determines whether the command can execute in its current state.

Defines the method to be called when the command is invoked.

Events summary

Occurs when changes occur that affect whether the command should execute.

Methods

  • CanExecute(System.Object)
    CanExecute(System.Object)
    CanExecute(System.Object)
    CanExecute(System.Object)

    Defines the method that determines whether the command can execute in its current state.

    public bool CanExecute(System.Object parameter)public bool CanExecute(System.Object parameter)Public Function CanExecute(parameter As System.Object) As bool

    Parameters

    • parameter
      System.Object
      System.Object
      System.Object

      Data used by the command. If the command does not require data to be passed, this object can be set to null.

    Returns

    • bool
      bool
      bool

      true if this command can be executed; otherwise, false.

  • Execute(System.Object)
    Execute(System.Object)
    Execute(System.Object)
    Execute(System.Object)

    Defines the method to be called when the command is invoked.

    public void Execute(System.Object parameter)public void Execute(System.Object parameter)Public Function Execute(parameter As System.Object) As void

    Parameters

    • parameter
      System.Object
      System.Object
      System.Object

      Data used by the command. If the command does not require data to be passed, can be set to null.

    Remarks

    When programming with .NET, this interface is hidden and developers should use the System.Windows.Input.ICommand interface.

Events

  • CanExecuteChanged
    CanExecuteChanged
    CanExecuteChanged
    CanExecuteChanged

    Occurs when changes occur that affect whether the command should execute.

    public abstract event EventHandler CanExecuteChangedpublic abstract event EventHandler CanExecuteChangedPublic MustInherit Event CanExecuteChanged

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.GuidAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Input.dll