PointHitTestResult.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 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.

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.

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

.NET Framework
Available since 3.0
Return to top