RoutedEventArgs.Handled 속성

정의

경로를 따라 이동할 때 라우트된 이벤트의 현재 이벤트 처리 상태를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Handled { bool get(); void set(bool value); };
public bool Handled { [System.Security.SecurityCritical] get; [System.Security.SecurityCritical] set; }
public bool Handled { get; set; }
[<get: System.Security.SecurityCritical>]
[<set: System.Security.SecurityCritical>]
member this.Handled : bool with get, set
member this.Handled : bool with get, set
Public Property Handled As Boolean

속성 값

이벤트를 처리된 것으로 표시하려면 true 로 설정하고, 그러지 않으면 false로 설정합니다. 이 값을 읽을 때 true 는 클래스 처리기 또는 경로의 일부 인스턴스 처리기가 이 이벤트를 처리한 것으로 이미 표시했음을 나타냅니다. false는 이러한 처리기가 이벤트를 처리한 것으로 표시하지 않았음을 나타냅니다.

기본값은 false입니다.

특성

예제

다음 예제에서는 이벤트를 처리 하는 표시 하는 이벤트 처리기를 구현 합니다.

protected override void OnPreviewMouseRightButtonDown(System.Windows.Input.MouseButtonEventArgs e)
{
    e.Handled = true; //suppress the click event and other leftmousebuttondown responders
    MyEditContainer ec = (MyEditContainer)e.Source;
    if (ec.EditState)
    { ec.EditState = false; }
    else
    { ec.EditState = true; }
    base.OnPreviewMouseRightButtonDown(e);
}
Protected Overrides Sub OnPreviewMouseRightButtonDown(ByVal e As System.Windows.Input.MouseButtonEventArgs)
    e.Handled = True 'suppress the click event and other leftmousebuttondown responders
    Dim ec As MyEditContainer = CType(e.Source, MyEditContainer)
    If ec.EditState Then
        ec.EditState = False
    Else
        ec.EditState = True
    End If
    MyBase.OnPreviewMouseRightButtonDown(e)
End Sub

설명

처리된 이벤트를 표시하면 라우트된 이벤트의 표시 유형이 이벤트 경로를 따라 수신기로 제한됩니다. 이벤트는 경로의 나머지 부분을 계속 이동하지만 메서드 호출에서 AddHandler(RoutedEvent, Delegate, Boolean) 를 사용하여 특별히 추가 HandledEventsTootrue 된 처리기만 응답으로 호출됩니다. instance 수신기(예: XAML(Extensible Application Markup Language)로 표현된 처리기)의 기본 처리기는 호출되지 않습니다. 처리된 것으로 표시된 이벤트를 처리하는 것은 일반적인 시나리오가 아닙니다.

사용자 고유의 이벤트를 정의하는 컨트롤 작성자인 경우 클래스 수준에서 이벤트 처리에 대한 결정은 컨트롤의 사용자뿐만 아니라 파생 컨트롤의 사용자 및 컨트롤에 포함되거나 컨트롤이 포함된 잠재적으로 다른 요소에 영향을 줍니다. 자세한 내용은 라우트된 이벤트를 처리된 것으로 표시 및 클래스 처리를 참조하세요.

매우 드문 경우에는 가 로 표시된 true이벤트를 Handled 처리하고 를 로 변경 Handled 하여 이벤트 인수를 수정하는 것이 false적절합니다. 이는 컨트롤의 특정 입력 이벤트 영역에서 필요할 수 있습니다. 예를 들어 의 키 처리 KeyDownTextInput 와 낮은 수준 및 높은 수준의 입력 이벤트가 처리를 위해 경쟁하는 위치 및 각각이 다른 라우팅 전략을 사용하려고 시도하는 경우 등이 필요할 수 있습니다.

적용 대상