HitTestFilterCallback 대리자

정의

적중 횟수 테스트 처리에서 생략할 시각적 트리 부분을 지정하는 콜백 메서드를 나타냅니다.

public delegate System::Windows::Media::HitTestFilterBehavior HitTestFilterCallback(DependencyObject ^ potentialHitTestTarget);
public delegate System.Windows.Media.HitTestFilterBehavior HitTestFilterCallback(DependencyObject potentialHitTestTarget);
type HitTestFilterCallback = delegate of DependencyObject -> HitTestFilterBehavior
Public Delegate Function HitTestFilterCallback(potentialHitTestTarget As DependencyObject) As HitTestFilterBehavior 

매개 변수

potentialHitTestTarget
DependencyObject

적중 횟수 테스트에 대한 시각적 개체입니다.

반환 값

HitTestFilterBehavior

적중 횟수 테스트에서 발생하는 작업을 나타내는 HitTestFilterBehavior입니다.

예제

다음 예제에서는 호출 하는 방법을 보여 줍니다 HitTest 를 사용 하 여를 HitTestFilterCallback 값입니다. 해당 하는 적중된 테스트 콜백 메서드 정의 됩니다.

// Respond to the mouse wheel event by setting up a hit test filter and results enumeration.
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
{
    // Retrieve the coordinate of the mouse position.
    Point pt = e.GetPosition((UIElement)sender);

    // Clear the contents of the list used for hit test results.
    hitResultsList.Clear();

    // Set up a callback to receive the hit test result enumeration.
    VisualTreeHelper.HitTest(myCanvas,
                      new HitTestFilterCallback(MyHitTestFilter),
                      new HitTestResultCallback(MyHitTestResult),
                      new PointHitTestParameters(pt));

    // Perform actions on the hit test results list.
    if (hitResultsList.Count > 0)
    {
        ProcessHitTestResultsList();
    }
}
' Respond to the mouse wheel event by setting up a hit test filter and results enumeration.
Private Overloads Sub OnMouseWheel(ByVal sender As Object, ByVal e As MouseWheelEventArgs)
    ' Retrieve the coordinate of the mouse position.
    Dim pt As Point = e.GetPosition(CType(sender, UIElement))

    ' Clear the contents of the list used for hit test results.
    hitResultsList.Clear()

    ' Set up a callback to receive the hit test result enumeration.
    VisualTreeHelper.HitTest(myCanvas, New HitTestFilterCallback(AddressOf MyHitTestFilter), New HitTestResultCallback(AddressOf MyHitTestResult), New PointHitTestParameters(pt))

    ' Perform actions on the hit test results list.
    If hitResultsList.Count > 0 Then
        ProcessHitTestResultsList()
    End If
End Sub

다음 예제에서는 반환 하는 방법을 보여 줍니다는 HitTestFilterBehavior 적중 횟수 테스트 필터 콜백 메서드에서 값입니다.

// Filter the hit test values for each object in the enumeration.
public HitTestFilterBehavior MyHitTestFilter(DependencyObject o)
{
    // Test for the object value you want to filter.
    if (o.GetType() == typeof(Label))
    {
        // Visual object and descendants are NOT part of hit test results enumeration.
        return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
    }
    else
    {
        // Visual object is part of hit test results enumeration.
        return HitTestFilterBehavior.Continue;
    }
}
' Filter the hit test values for each object in the enumeration.
Public Function MyHitTestFilter(ByVal o As DependencyObject) As HitTestFilterBehavior
    ' Test for the object value you want to filter.
    If o.GetType() Is GetType(Label) Then
        ' Visual object and descendants are NOT part of hit test results enumeration.
        Return HitTestFilterBehavior.ContinueSkipSelfAndChildren
    Else
        ' Visual object is part of hit test results enumeration.
        Return HitTestFilterBehavior.Continue
    End If
End Function

설명

적중 횟수 테스트 필터 콜백 메서드에서 적중 횟수 테스트 조건에 사용자 지정 시각적 개체에서 시작 하 고 시각적 트리의 분기까지 내림차순으로 매핑되는 모든 시각적 개체에 대 한 호출 됩니다. 그렇지만 적중 테스트 결과 콜백 함수에서 처리하지 않으려는 시각적 트리의 특정 분기를 무시하고 싶을 수 있습니다. 적중 테스트 필터 콜백 함수의 반환 값은 수행해야 하는 시각적 개체의 열거 작업 유형을 결정합니다. 예를 들어, 값을 반환 하는 경우 ContinueSkipSelfAndChildren, 적중 횟수 테스트 결과 열거에서 현재 시각적 개체 및 해당 하위 항목을 제거할 수 있습니다. 즉, 적중 횟수 테스트 결과 콜백 메서드 열거에 이러한 개체를 표시 되지 않습니다.

참고

개체의 시각적 트리를 정리하면 적중 테스트 결과 열거 패스 동안 처리 양이 감소합니다.

적중 테스트 필터를 사용하여 시각적 트리 정리
시각적 트리 정리

확장 메서드

GetMethodInfo(Delegate)

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

적용 대상

추가 정보