Export (0) Print
Expand All
Expand Minimize

HitTestFilterBehavior Enumeration

Specifies the return behavior of a hit test in a hit test filter callback method.

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

public enum HitTestFilterBehavior
<object property="enumerationMemberName" .../>

Member nameDescription
ContinueHit test against the current Visual and its descendants.
ContinueSkipChildrenHit test against the current Visual, but not its descendants.
ContinueSkipSelfDo not hit test against the current Visual, but hit test against its descendants.
ContinueSkipSelfAndChildrenDo not hit test against the current Visual or its descendants.
StopStop hit testing at the current Visual.

The return value of the hit test filter callback is a HitTestFilterBehavior, which determines what type of action should be taken when processing the visual tree for hit testing. For example, if your hit test filter callback return the value, ContinueSkipSelfAndChildren, you can remove the current visual object and its descendants from the hit test results evaluation.

NoteNote

Pruning the visual tree of objects decreases the amount of processing that is required during the hit test results evaluation pass.

Pruning a visual tree

Pruning a visual tree using a hit test filter

The following example shows how to return a HitTestFilterBehavior value from a hit test filter callback method. In this case, the filter skips labels and their descendants and hit tests everything else.

// 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;
    }
}

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft