VisualHit Property
Collapse the table of content
Expand the table of content

GeometryHitTestResult.VisualHit Property

 

Gets the visual object that is returned from a hit test result.

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

public Visual VisualHit { get; }

Property Value

Type: System.Windows.Media.Visual

A Visual object that represents the hit test result.

The following example shows how to reference the value of the VisualHit property in a hit test callback procedure.

// Return the result of the hit test to the callback.
public HitTestResultBehavior MyHitTestResultCallback(HitTestResult result)
{
    // Retrieve the results of the hit test.
    IntersectionDetail intersectionDetail = ((GeometryHitTestResult)result).IntersectionDetail;

    switch (intersectionDetail)
    {
        case IntersectionDetail.FullyContains:

            // Add the hit test result to the list that will be processed after the enumeration.
            hitResultsList.Add(result.VisualHit);

            return HitTestResultBehavior.Continue;

        case IntersectionDetail.Intersects:

            // Set the behavior to return visuals at all z-order levels.
            return HitTestResultBehavior.Continue;

        case IntersectionDetail.FullyInside:

            // Set the behavior to return visuals at all z-order levels.
            return HitTestResultBehavior.Continue;

        default:
            return HitTestResultBehavior.Stop;
    }
}

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft