GeometryHitTestParameters(Geometry) 构造函数

定义

使用指定的 Geometry 初始化 GeometryHitTestParameters 类的新实例。

public:
 GeometryHitTestParameters(System::Windows::Media::Geometry ^ geometry);
public GeometryHitTestParameters (System.Windows.Media.Geometry geometry);
new System.Windows.Media.GeometryHitTestParameters : System.Windows.Media.Geometry -> System.Windows.Media.GeometryHitTestParameters
Public Sub New (geometry As Geometry)

参数

geometry
Geometry

用于命中测试几何图形的 Geometry 值。

示例

以下示例演示如何通过 对 HitTest 方法使用 GeometryHitTestParameters 设置命中测试。 Point值用于创建 Geometry 对象,以将命中测试的范围扩展到更宽的显示区域。

// Retrieve the coordinate of the mouse position.
Point pt = e.GetPosition((UIElement)sender);

// Expand the hit test area by creating a geometry centered on the hit test point.
EllipseGeometry expandedHitTestArea = new EllipseGeometry(pt, 10.0, 10.0);

// Set up a callback to receive the hit test result enumeration.
VisualTreeHelper.HitTest(myControl, null,
    new HitTestResultCallback(MyHitTestResultCallback),
    new GeometryHitTestParameters(expandedHitTestArea));
' 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)

' Set up a callback to receive the hit test result enumeration.
VisualTreeHelper.HitTest(myControl, Nothing, New HitTestResultCallback(AddressOf MyHitTestResultCallback), New GeometryHitTestParameters(expandedHitTestArea))

适用于

另请参阅