CommandBinding.Executed 이벤트

정의

CommandBinding에 연결된 명령이 실행되면 발생합니다.Occurs when the command associated with this CommandBinding executes.

public:
 event System::Windows::Input::ExecutedRoutedEventHandler ^ Executed;
public event System.Windows.Input.ExecutedRoutedEventHandler Executed;
member this.Executed : System.Windows.Input.ExecutedRoutedEventHandler 
Public Event Executed As ExecutedRoutedEventHandler 

예제

다음 예제에서는 CommandBinding 매핑되는 ExecutedRoutedEventHandlerCanExecuteRoutedEventArgs 처리기를 Open 명령 합니다.The following example creates a CommandBinding that maps an ExecutedRoutedEventHandler and a CanExecuteRoutedEventArgs handler to the 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);
' Creating CommandBinding and attaching an Executed and CanExecute handler
Dim OpenCmdBinding As New CommandBinding(ApplicationCommands.Open, AddressOf OpenCmdExecuted, AddressOf OpenCmdCanExecute)

Me.CommandBindings.Add(OpenCmdBinding)

에서는 다음 합니다 ExecutedRoutedEventHandler 만듭니다는 MessageBox 명령이 실행 되는 경우.The following shows the ExecutedRoutedEventHandler which creates a 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);
}
Private Sub OpenCmdExecuted(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
    Dim command, targetobj As String
    command = CType(e.Command, RoutedCommand).Name
    targetobj = CType(sender, FrameworkElement).Name
    MessageBox.Show("The " + command + " command has been invoked on target object " + targetobj)
End Sub

설명

경우는 RoutedCommand 실행 발생는 PreviewExecuted 명령 대상에서 이벤트입니다.When a RoutedCommand executes, it raises the PreviewExecuted event on the command target. 경우는 PreviewExecuted 이벤트가 처리 되지 않은 Executed 명령 대상에서 이벤트가 발생 합니다.If the PreviewExecuted event is not handled, the Executed event is raised on the command target. 명령 대상에는 CommandBinding 특정 명령에 대 한는 Executed 에 대 한 처리기 CommandBinding 라고 합니다.If the command target has a CommandBinding for the specific command, the Executed handler for that CommandBinding is called. 명령 대상에 없는 경우는 CommandBinding 해당 특정 명령에 대 한는 Executed 있는 요소를 검색 하는 요소 트리를 이벤트 버블링을 CommandBinding 명령과 사용 하 여 연결 합니다.If the command target does not have a CommandBinding for that specific command the Executed event bubbles up the element tree searching for an element that has a CommandBinding associated with the command. 경우는 CommandBinding 발견 되지 않으면이 명령은 처리 되지 않습니다.If a CommandBinding is not found, the command is not handled.

라우팅 이벤트 정보Routed Event Information

식별자 필드Identifier field ExecutedEvent
라우팅 전략Routing strategy 버블링Bubbling
대리자Delegate ExecutedRoutedEventHandler

적용 대상

추가 정보