Specifies a Geometry as the parameter to be used for hit testing a visual tree.
Assembly: PresentationCore (in PresentationCore.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Windows Presentation Foundation (WPF) hit testing only considers the filled area of a geometry during a hit test. If you create a point Geometry, the hit test would not intersect anything because a point has no area.
The following example shows how to set up a hit test using for the HitTest method. The Point value that is passed to the OnMouseDown method is used to create a Geometry object in order to expand the range of the hit test.
' Respond to the mouse button down event by setting up a hit test results callback. Private Overloads Sub OnMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) ' Retrieve the coordinate of the mouse position. Dim pt As Point = e.GetPosition(CType(sender, UIElement)) ' Expand the hit test area by creating a geometry centered on the hit test point. Dim expandedHitTestArea As New EllipseGeometry(pt, 10.0, 10.0) ' Clear the contents of the list used for hit test results. hitResultsList.Clear() ' Set up a callback to receive the hit test result enumeration. VisualTreeHelper.HitTest(myControl, Nothing, New HitTestResultCallback(AddressOf MyHitTestResultCallback), New GeometryHitTestParameters(expandedHitTestArea)) ' Perform actions on the hit test results list. If hitResultsList.Count > 0 Then ProcessHitTestResultsList() End If End Sub
The IntersectionDetail property of GeometryHitTestResult provides information about the results of a hit test that uses a Geometry as a hit test parameter. The following illustration shows the relationship between the hit test geometry (the blue circle) and the target object (the red square).
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.