CanExecuteRoutedEventArgs クラス

定義

CanExecuteおよびPreviewCanExecuteルーティング イベントのデータを提供します。

public ref class CanExecuteRoutedEventArgs sealed : System::Windows::RoutedEventArgs
public sealed class CanExecuteRoutedEventArgs : System.Windows.RoutedEventArgs
type CanExecuteRoutedEventArgs = class
    inherit RoutedEventArgs
Public NotInheritable Class CanExecuteRoutedEventArgs
Inherits RoutedEventArgs
継承
CanExecuteRoutedEventArgs

次の例では、コマンド ターゲットがコントロールの場合にのみCanExecuteRoutedEventHandlerを返すtrueを作成します。 まず、 SourceControlにキャストされます。 SourceControlの場合、CanExecutetrueに設定されます。それ以外の場合は、falseに設定されます。

// CanExecuteRoutedEventHandler that only returns true if
// the source is a control.
private void CanExecuteCustomCommand(object sender, 
    CanExecuteRoutedEventArgs e)
{
    Control target = e.Source as Control;
    
    if(target != null)
    {
        e.CanExecute = true;
    }
    else
    {
        e.CanExecute = false;
    }
}
' CanExecuteRoutedEventHandler that only returns true if
' the source is a control.
Private Sub CanExecuteCustomCommand(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
    Dim target As Control = TryCast(e.Source, Control)

    If target IsNot Nothing Then
        e.CanExecute = True
    Else
        e.CanExecute = False
    End If
End Sub

注釈

通常、コマンド ソース (このようなMenuItem) は、CanExecuteRoutedCommand メソッドを呼び出して、コマンドが現在のコマンド ターゲットで実行できるかどうかを判断します。 CanExecuteがイベント ハンドラーからfalseに設定されている場合、コマンド ソースはそれ自体を無効にします。 たとえば、 MenuItem がコマンドのコマンド ソースとして機能していて、現在のコマンド ターゲットでコマンドを実行できない場合、 MenuItem はグレー表示になります。

CanExecuteChanged イベントは、実行するコマンドの機能が変更された可能性がある場合に、コマンド ソースに通知します。

プロパティ

名前 説明
CanExecute

このイベントに関連付けられている RoutedCommand をコマンド ターゲットで実行できるかどうかを示す値を取得または設定します。

Command

このイベントに関連付けられているコマンドを取得します。

ContinueRouting

コマンドを呼び出した入力ルーティング イベントが要素ツリー経由で引き続きルーティングされる必要があるかどうかを判断します。

Handled

ルーティング イベントがルートを移動する際のイベント処理の現在の状態を示す値を取得または設定します。

(継承元 RoutedEventArgs)
OriginalSource

親クラスによって可能な Source 調整の前に、純粋ヒット テストによって決定された元のレポート ソースを取得します。

(継承元 RoutedEventArgs)
Parameter

コマンド固有のデータを取得します。

RoutedEvent

このRoutedEvent インスタンスに関連付けられているRoutedEventArgsを取得または設定します。

(継承元 RoutedEventArgs)
Source

イベントを発生させたオブジェクトへの参照を取得または設定します。

(継承元 RoutedEventArgs)

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InvokeEventHandler(Delegate, Object)

派生クラスでオーバーライドされると、型固有の方法でイベント ハンドラーを呼び出す方法が提供され、基本実装の効率が向上する可能性があります。

(継承元 RoutedEventArgs)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
OnSetSource(Object)

派生クラスでオーバーライドされると、インスタンスの Source プロパティの値が変更されるたびに通知コールバック エントリ ポイントを提供します。

(継承元 RoutedEventArgs)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください