CommandBinding.Executed 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이와 CommandBinding 연결된 명령이 실행될 때 발생합니다.
public:
event System::Windows::Input::ExecutedRoutedEventHandler ^ Executed;
public event System.Windows.Input.ExecutedRoutedEventHandler Executed;
member this.Executed : System.Windows.Input.ExecutedRoutedEventHandler
Public Custom Event Executed As ExecutedRoutedEventHandler
Public Event Executed As ExecutedRoutedEventHandler
이벤트 유형
예제
다음 예제에서는 명령과 CommandBinding 처리기를 매핑 ExecutedRoutedEventHandler 하는 CanExecuteRoutedEventArgs 메서드를 Open 만듭니다.
<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 만드는 방법을 보여줍니다.
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 이벤트가 발생합니다. PreviewExecuted 이벤트가 처리되지 Executed 않으면 명령 대상에서 이벤트가 발생합니다. 명령 대상 CommandBinding 에 특정 명령에 대한 처리 Executed 기가 있는 경우 해당 CommandBinding 처리기가 호출됩니다. 명령 대상에 특정 명령에 대한 명령이 없는 CommandBinding 경우 이벤트는 명령 Executed 과 연결된 요소를 검색하는 CommandBinding 요소 트리를 버블업합니다. a를 CommandBinding 찾을 수 없으면 명령이 처리되지 않습니다.
라우트된 이벤트 정보
| 항목 | 가치 |
|---|---|
| 식별자 필드 | ExecutedEvent |
| 라우팅 전략 | 버블링 |
| 대리자 | ExecutedRoutedEventHandler |
- 해당 터널링 이벤트는 PreviewExecuted.