Command<T> 构造函数

定义

重载

Command<T>(Action<T>)

初始化 Command 类的新实例。

Command<T>(Action<T>, Func<T,Boolean>)

初始化 Command 类的新实例。

Command<T>(Action<T>)

Source:
Command.cs
Source:
Command.cs

初始化 Command 类的新实例。

public:
 Command(Action<T> ^ execute);
public Command (Action<T> execute);
new Microsoft.Maui.Controls.Command<'T> : Action<'T> -> Microsoft.Maui.Controls.Command<'T>
Public Sub New (execute As Action(Of T))

参数

execute
Action<T>

要在执行命令时执行的操作。

适用于

Command<T>(Action<T>, Func<T,Boolean>)

Source:
Command.cs
Source:
Command.cs

初始化 Command 类的新实例。

public:
 Command(Action<T> ^ execute, Func<T, bool> ^ canExecute);
public Command (Action<T> execute, Func<T,bool> canExecute);
new Microsoft.Maui.Controls.Command<'T> : Action<'T> * Func<'T, bool> -> Microsoft.Maui.Controls.Command<'T>
Public Sub New (execute As Action(Of T), canExecute As Func(Of T, Boolean))

参数

execute
Action<T>

要在执行命令时执行的 Action<object>。

canExecute
Func<T,Boolean>

指示是否能执行命令的 Func<T,TResult>

注解

每当 canExecute 返回的值发生更改时,都需要调用 ChangeCanExecute() 以触发 CanExecuteChanged

适用于