RoutedEventArgs.Handled 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
경로를 따라 이동할 때 라우트된 이벤트의 현재 이벤트 처리 상태를 나타내는 값을 가져오거나 설정합니다.
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) 특별히 추가 HandledEventsToo
true
된 처리기만 응답으로 호출됩니다. 인스턴스 수신기의 기본 처리기(예: XAML(Extensible Application Markup Language)로 표현됨)는 호출되지 않습니다. 처리된 것으로 표시된 이벤트 처리는 일반적인 시나리오가 아닙니다.
사용자 고유의 이벤트를 정의하는 컨트롤 작성자인 경우 클래스 수준에서 이벤트 처리에 대한 결정은 컨트롤의 사용자뿐만 아니라 파생된 컨트롤의 사용자 및 컨트롤에 포함되거나 컨트롤이 포함된 잠재적으로 다른 요소에도 영향을 줍니다. 자세한 내용은 라우트된 이벤트를 처리된 것으로 표시 및 클래스 처리를 참조하세요.
매우 드문 경우로 표시된 true
이벤트를 Handled 처리하고 이벤트 인수를 변경 Handled 하여 수정하는 것이 false
적절합니다. 이는 낮은 수준 및 높은 수준의 입력 이벤트가 처리를 위해 경쟁하고 각각이 다른 라우팅 전략을 사용하려고 하는 경우와 비교한 키 처리와 같은 컨트롤의 KeyDown TextInput 입력 이벤트의 특정 영역에서 필요할 수 있습니다.