GeometryHitTestParameters(Geometry) 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用指定的 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)
参数
示例
以下示例演示如何通过 对 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))