HitTestFilterCallback Delegate
Collapse the table of content
Expand the table of content

HitTestFilterCallback Delegate


Represents the callback method that specifies parts of the to omit from hit test processingGTMT

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public delegate HitTestFilterBehavior HitTestFilterCallback(
	DependencyObject potentialHitTestTarget


Type: System.Windows.DependencyObject

The visual to hit test.

Return Value

Type: System.Windows.Media.HitTestFilterBehavior

A HitTestFilterBehavior that represents the action resulting from the hit test.

The hit test filter callback method is invoked for all the visual objects that map to the hit test criteria, starting from the visual you specify and descending through its branch of the visual tree. However, you may want to ignore certain branches of the visual tree that you are not interested in processing in your hit test results callback function. The return value of the hit test filter callback function determines what type of action the enumeration of the visual objects should take. For example, if you return the value, ContinueSkipSelfAndChildren, you can remove the current visual object and its descendants from the hit test results enumeration. This means that the hit test results callback method will not see these objects in its enumeration.


Pruning the visual tree of objects decreases the amount of processing during the hit test results enumeration pass.

Pruning a visual tree using a hit test filter

Pruning a visual tree

Legacy Code Example

The following example shows how to invoke HitTest by using a HitTestFilterCallback value. The corresponding hit test callback method is also defined.

Code snippet is not found. Confirm that the code snippet name 'HitTestingOverview' is correct.

The following example shows how to return a HitTestFilterBehavior value from a hit test filter callback method.

Code snippet is not found. Confirm that the code snippet name 'HitTestingOverview' is correct.

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft