ExecutedRoutedEventHandler 대리자

정의

관련 연결된 이벤트뿐만 아니라 ExecutedPreviewExecuted 라우트된 이벤트를 처리할 메서드를 나타냅니다.

public delegate void ExecutedRoutedEventHandler(System::Object ^ sender, ExecutedRoutedEventArgs ^ e);
public delegate void ExecutedRoutedEventHandler(object sender, ExecutedRoutedEventArgs e);
type ExecutedRoutedEventHandler = delegate of obj * ExecutedRoutedEventArgs -> unit
Public Delegate Sub ExecutedRoutedEventHandler(sender As Object, e As ExecutedRoutedEventArgs)

매개 변수

sender
Object

이벤트 처리기가 연결된 개체입니다.

e
ExecutedRoutedEventArgs

이벤트 데이터입니다.

예제

이 예제에서는 ExecutedRoutedEventHandler 명령이 실행 될 때 대상의 시각적 속성을 설정 하는 합니다. 이 예제에서는 또한는 CanExecuteRoutedEventHandler 동일한 명령에 대 한 합니다.

// ExecutedRoutedEventHandler for the custom color command.
private void ColorCmdExecuted(object sender, ExecutedRoutedEventArgs e)
{
    Panel target = e.Source as Panel;
    if (target != null)
    {
        if (target.Background == Brushes.AliceBlue)
        {
            target.Background = Brushes.LemonChiffon;
        }
        else
        {
            target.Background = Brushes.AliceBlue;
        }
    }
}

// CanExecuteRoutedEventHandler for the custom color command.
private void ColorCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    if (e.Source is Panel)
    {
        e.CanExecute = true;
    }
    else
    {
        e.CanExecute = false;
    }
}
' ExecutedRoutedEventHandler for the custom color command.
Private Sub ColorCmdExecuted(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
    Dim target As Panel = TryCast(e.Source, Panel)
    If target IsNot Nothing Then
        If target.Background Is Brushes.AliceBlue Then
            target.Background = Brushes.LemonChiffon
        Else
            target.Background = Brushes.AliceBlue
        End If

    End If
End Sub

' CanExecuteRoutedEventHandler for the custom color command.
Private Sub ColorCmdCanExecute(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
    If TypeOf e.Source Is Panel Then
        e.CanExecute = True
    Else
        e.CanExecute = False
    End If
End Sub

설명

이 대리자에 대 한 구현 논리가 포함 된 RoutedCommand합니다. 명령의 구현 논리 분리를 사용 하면 다양 한 원본 및 형식에서 호출할 명령을 하 고 명령 논리를 중앙 집중식을 활성화 합니다.

이 대리자에도 사용 됩니다 CommandManager.Executed 하 고 CommandManager.PreviewExecuted에 연결 된 이벤트는는 CommandManager 많은 명령 인프라를 구현 하는 클래스입니다. 가장 유용한 처리기를 처리할 수는 Executed 특정 이벤트 CommandBinding아닌 근무 보다는 CommandManager 수준입니다.

ExecutedRoutedEventArgs, 다음 속성은 일반적으로 관심 실행된 명령에서 발생 하는 라우트된 이벤트에 대 한 이벤트 처리기를 작성 하는 경우:

  • Source 대상 명령이 실행 된 위치를 보고 합니다. 명령이 실행 되 면 생각할 수 있습니다도 Source 더 일반적으로 라우트된 이벤트 관점에서 라우트된 이벤트를 발생 시킨 개체입니다.

  • Command 명령 실행을 보고 합니다. 이 속성은 명령 바인딩을 사용 하는 경우 및 잠재적으로 여러 명령을 처리 하는 처리기를 작성 하는 경우에 유용 합니다.

  • Parameter 실행 명령에 의해 전달 된 명령 관련 매개 변수를 보고 합니다. 일부 명령을 사용 하거나 명령 관련 매개 변수가 필요 합니다.

  • Handled 실행된 된 명령에서 발생 하는 라우트된 이벤트가 경로의 다른 요소에서 이미 처리 되었는지 여부를 보고 합니다. 라우트된 이벤트 처리기에 대 한 것이 좋습니다 설정 하는 이벤트를 처리 하는 경우 의미 있는 작업을 수행 하는 처리기가 Handledtrue입니다. 이 이벤트는 다시 경로 따라 추가로 처리에서 이벤트에 대 한 일반적인 처리기를 방지 합니다. 라우트된 이벤트를 처리 하는 방법은 참조 하세요 라우트된 이벤트 것으로 표시를 처리 및 클래스 처리합니다.

이 대리자에 대 한 처리기 나타냅니다 CommandManager.ExecutedCommandManager.PreviewExecutedEvent, 이벤트에 연결 되는 CommandManager 많은 명령 인프라를 구현 하는 클래스입니다. 가장 유용한 처리기를 처리할 수는 Executed 특정 이벤트 CommandBinding아닌 근무 보다는 CommandManager 수준입니다.

명령에 대한 자세한 내용은 명령 개요를 참조하세요.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보