HitTestFilterCallback 대리자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
적중 테스트 처리에서 생략할 시각적 트리의 일부를 지정하는 콜백 메서드를 나타냅니다.
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
적중 테스트할 시각적 개체입니다.
반환 값
적중 테스트에서 발생한 동작을 나타내는 A 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반환하는 경우 적중 테스트 결과 열거형에서 현재 시각적 개체와 해당 하위 항목을 제거할 수 있습니다. 즉, 적중 테스트 결과 콜백 메서드는 열거형에서 이러한 개체를 볼 수 없습니다.
메모
개체의 시각적 트리를 정리하면 적중 테스트 결과 열거 패스 동안 처리 양이 감소합니다.
를 시각적 트리 정리
확장명 메서드
| Name | Description |
|---|---|
| GetMethodInfo(Delegate) |
지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다. |