다음을 통해 공유


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 사용하여 특별히 추가된 처리기만 응답으로 호출됩니다. 인스턴스 수신기의 기본 처리기(예: XAML(Extensible Application Markup Language))는 호출되지 않습니다. 처리된 것으로 표시된 이벤트를 처리하는 것은 일반적인 시나리오가 아닙니다.

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

매우 드문 경우지만 Handledtrue표시된 이벤트를 처리하고 Handledfalse변경하여 이벤트 인수를 수정하는 것이 적절합니다. 낮은 수준 및 높은 수준의 입력 이벤트가 처리를 위해 경쟁하고 각각 다른 라우팅 전략을 사용하려고 하는 TextInputKeyDown 키 처리와 같은 컨트롤의 입력 이벤트의 특정 영역에서 필요할 수 있습니다.

적용 대상