この記事は機械翻訳されています。英語版の記事を表示するには、[英語] のチェック ボックスをオンにしてください。また、テキストにマウス ポインターを合わせると、ポップアップ ウィンドウに英語のテキストを表示することもできます。
翻訳
英語

CommandBinding.Executed イベント

 

公開日: 2016年10月

この CommandBinding に関連付けられたコマンドが実行されたときに発生します。

名前空間:   System.Windows.Input
アセンブリ:  PresentationCore (PresentationCore.dll 内)

public event ExecutedRoutedEventHandler Executed

When a T:System.Windows.Input.RoutedCommand executes, it raises the E:System.Windows.Input.CommandBinding.PreviewExecuted event on the command target. If the E:System.Windows.Input.CommandBinding.PreviewExecuted event is not handled, the E:System.Windows.Input.CommandBinding.Executed event is raised on the command target. If the command target has a T:System.Windows.Input.CommandBinding for the specific command, the E:System.Windows.Input.CommandBinding.Executed handler for that T:System.Windows.Input.CommandBinding is called. If the command target does not have a T:System.Windows.Input.CommandBinding for that specific command the E:System.Windows.Input.CommandBinding.Executed event bubbles up the element tree searching for an element that has a T:System.Windows.Input.CommandBinding associated with the command. If a T:System.Windows.Input.CommandBinding is not found, the command is not handled.

Identifier field

ExecutedEvent

Routing strategy

Bubbling

Delegate

ExecutedRoutedEventHandler

  • The corresponding tunneling event is E:System.Windows.Input.CommandBinding.PreviewExecuted.

The following example creates a T:System.Windows.Input.CommandBinding that maps an T:System.Windows.Input.ExecutedRoutedEventHandler and a T:System.Windows.Input.CanExecuteRoutedEventArgs handler to the P:System.Windows.Input.ApplicationCommands.Open command.

<Window.CommandBindings>
  <CommandBinding Command="ApplicationCommands.Open"
                  Executed="OpenCmdExecuted"
                  CanExecute="OpenCmdCanExecute"/>
</Window.CommandBindings>
// Creating CommandBinding and attaching an Executed and CanExecute handler
CommandBinding OpenCmdBinding = new CommandBinding(
    ApplicationCommands.Open,
    OpenCmdExecuted,
    OpenCmdCanExecute);

this.CommandBindings.Add(OpenCmdBinding);

The following shows the T:System.Windows.Input.ExecutedRoutedEventHandler which creates a T:System.Windows.MessageBox when the command is executed.

void OpenCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
    String command, targetobj;
    command = ((RoutedCommand)e.Command).Name;
    targetobj = ((FrameworkElement)target).Name;
    MessageBox.Show("The " + command +  " command has been invoked on target object " + targetobj);
}

.NET Framework
3.0 以降で使用可能
トップに戻る
表示: