Command 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
public ref class Command : System::Windows::Input::ICommand
public class Command : System.Windows.Input.ICommand
type Command = class
interface ICommand
Public Class Command
Implements ICommand
- 繼承
-
Command
- 衍生
- 實作
備註
下列範例會建立新的 Command,並將其設定為按鈕。
var command = new Command (() => Debug.WriteLine ("Command executed"));
var button = new Button {
Text = "Hit me to execute the command",
Command = command,
};
更實用的案例會採用 參數
var command = new Command (o => Debug.WriteLine ("Command executed: {0}", o));
var button = new Button {
Text = "Hit me to execute the command",
Command = command,
CommandParameter = "button0",
};
建構函式
Command(Action, Func<Boolean>) |
初始化 Command 類別的新執行個體。 |
Command(Action) |
初始化 Command 類別的新執行個體。 |
Command(Action<Object>, Func<Object,Boolean>) |
初始化 Command 類別的新執行個體。 |
Command(Action<Object>) |
初始化 Command 類別的新執行個體。 |
方法
CanExecute(Object) |
傳回 Boolean,指出是否可以使用指定的參數來執行 Command。 |
ChangeCanExecute() | |
Execute(Object) |
叫用 execute Action |
事件
CanExecuteChanged |