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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

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

 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 function is a HitTestFilterBehavior, which 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.

NoteNote:

Pruning the visual tree of objects decreases the amount of processing during the hit test results enumeration 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;
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft