ICommand インターフェイス

定義

コマンドを定義します。

public interface class ICommand
public interface ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public interface ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public interface ICommand
type ICommand = interface
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type ICommand = interface
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type ICommand = interface
Public Interface ICommand
派生
属性

注釈

RoutedCommandWindows Presentation Foundation RoutedUICommand (WPF) のインターフェイスの ICommand 2 つの実装です。

Windows ランタイム アプリの ICommand

インターフェイスはICommand、Windows ランタイム アプリ用に .NET で記述されたコマンドのコード コントラクトです。 これらのコマンドは、Windows ランタイム XAML Button などの UI 要素、特に AppBarButton. Windows ランタイム アプリのコマンドを定義する場合は、基本的に .NET アプリのコマンドの定義に使用するのと同じ手法を使用します。 メソッドを実装し、具体的に実装 ICommand するクラスを定義して、コマンドを実装します Execute

Windows ランタイム用の XAML は x:Static をサポートしていないため、コマンドが XAML から使用x:Staticされる場合はマークアップ拡張Windows ランタイム使用しないでください。 また、Windows ランタイムには定義済みのコマンド ライブラリがないため、ここで示す XAML 構文は、インターフェイスを実装し、Windows ランタイム使用するためのコマンドを定義する場合には実際には適用されません。

XAML 属性の使用方法

<object property="predefinedCommandName"/>

- または -

<object property="predefinedClassName.predefinedCommandName"/>

- または -

<object property="{ customClassName.customCommandName}"/>

XAML 値

predefinedClassName
定義済みのコマンド クラスの 1 つ。

predefinedCommandName
定義済みのコマンドの 1 つ。

customClassName
カスタム コマンドを含むカスタム クラス。 カスタム クラスには通常、プレフィックス マッピングが必要です xlmnsWPF XAML の XAML 名前空間と名前空間マッピングに関する説明を参照してください。

customCommandName
カスタム コマンド。

メソッド

CanExecute(Object)

現在の状態でコマンドが実行可能かどうかを決定するメソッドを定義します。

Execute(Object)

コマンドが起動される際に呼び出すメソッドを定義します。

events

CanExecuteChanged

コマンドを実行するかどうかに影響するような変更があった場合に発生します。

適用対象