แก้ไข

แชร์ผ่าน


PointHitTestResult.VisualHit Property

Definition

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

public:
 property System::Windows::Media::Visual ^ VisualHit { System::Windows::Media::Visual ^ get(); };
public System.Windows.Media.Visual VisualHit { get; }
member this.VisualHit : System.Windows.Media.Visual
Public ReadOnly Property VisualHit As Visual

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;
}
' Return the result of the hit test to the callback.
Public Function MyHitTestResult(ByVal result As HitTestResult) As HitTestResultBehavior
    ' 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
End Function

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