GeometryHitTestResult.IntersectionDetail Property

Definition

Gets the IntersectionDetail value of the hit test.

C#
public System.Windows.Media.IntersectionDetail IntersectionDetail { get; }

Property Value

The IntersectionDetail value of the hit test.

Examples

The following example shows how to use the IntersectionDetail property of GeometryHitTestResult.

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

Remarks

The IntersectionDetail property describes the intersection between a Geometry and the target visual object.

The following illustration shows the relationship between the hit test geometry (the blue circle) and the target object (the red square).

Diagram of IntersectionDetail used in hit testing
The intersection between a hit test geometry and a target object

Applies to

Produkt Verzie
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10