ICommand ICommand ICommand ICommand Interface

Definition

Defines the contract for commanding.

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

public : interface ICommand
struct winrt::Windows::UI::Xaml::Input::ICommand
public interface ICommand
Public Interface ICommand
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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

CanExecute(Object) CanExecute(Object) CanExecute(Object) CanExecute(Object)

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

public : Platform::Boolean CanExecute(Platform::Object parameter)
bool CanExecute(winrt::Windows::Foundation::IInspectable parameter) const;
public bool CanExecute(Object parameter)
Public Function CanExecute(parameter As Object) As bool
Parameters
parameter
Object 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

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

Execute(Object) Execute(Object) Execute(Object) Execute(Object)

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

public : void Execute(Platform::Object parameter)
void Execute(winrt::Windows::Foundation::IInspectable parameter) const;
public void Execute(Object parameter)
Public Function Execute(parameter As Object) As void
Parameters
parameter
Object 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 : event EventHandler CanExecuteChanged<Platform::Object>
// Register
event_token CanExecuteChanged(EventHandler<Platform::Object> const& handler) const;

// Revoke with event_token
void CanExecuteChanged(event_token const& cookie) const;

// Revoke with event_revoker
CanExecuteChanged_revoker CanExecuteChanged(auto_revoker_t, EventHandler<Platform::Object> const& handler) const;
public event EventHandler CanExecuteChanged<object>
Public Event EventHandler CanExecuteChanged( Of ( Of object ))