PointHitTestResult.VisualHit Property

Definition

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

public System.Windows.Media.Visual VisualHit { get; }

Property Value

A Visual object that represents the hit test result.

Examples

The following example shows how to access the VisualHit property in a hit test results callback function.

// Return the result of the hit test to the callback.
public HitTestResultBehavior MyHitTestResult(HitTestResult result)
{
    // Add the hit test result to the list that will be processed after the enumeration.
    hitResultsList.Add(result.VisualHit);

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

Remarks

The VisualHit value could potentially represent multiple visual objects during a single hit test. The hit test callback method defines the actions you perform when a hit test is identified on a particular visual object in the visual tree. After you perform the actions, you return a HitTestResultBehavior value that determines whether to continue the enumeration of any other visual objects. The order of enumeration of returned visual objects is by z-order on the rendering plane.

Applies to

Produto Versões
.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