VisualTreeHelper.HitTest Method (Visual, Point)
Assembly: PresentationCore (in PresentationCore.dll)
Public Shared Function HitTest ( reference As Visual, point As Point ) As HitTestResult
The point value to hit test against.
It is possible for a hit test that starts in a 2D visual tree to return RayHitTestResult, which is a 3D hit test result object. Hit testing that starts in a 2D visual tree seamlessly extends into any defined 3D visual tree.
The following example shows how to use the Canvas.method to hit test the objects within a
' Respond to the left mouse button down event by initiating the hit test. Private Overloads Sub OnMouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) ' Retrieve the coordinate of the mouse position. Dim pt As Point = e.GetPosition(CType(sender, UIElement)) ' Perform the hit test against a given portion of the visual object tree. Dim result As HitTestResult = VisualTreeHelper.HitTest(myCanvas, pt) If result IsNot Nothing Then ' Perform action on hit visual object. End If End Sub
Available since 3.0