Visual.HitTestCore 方法

定义

确定点或几何图形值是否在可视对象的边界内。

重载

HitTestCore(GeometryHitTestParameters)

确定可视对象的边界中是否存在几何图形值。

HitTestCore(PointHitTestParameters)

确定点坐标值是否在可视对象的边界内。

HitTestCore(GeometryHitTestParameters)

确定可视对象的边界中是否存在几何图形值。

protected:
 virtual System::Windows::Media::GeometryHitTestResult ^ HitTestCore(System::Windows::Media::GeometryHitTestParameters ^ hitTestParameters);
protected virtual System.Windows.Media.GeometryHitTestResult HitTestCore (System.Windows.Media.GeometryHitTestParameters hitTestParameters);
abstract member HitTestCore : System.Windows.Media.GeometryHitTestParameters -> System.Windows.Media.GeometryHitTestResult
override this.HitTestCore : System.Windows.Media.GeometryHitTestParameters -> System.Windows.Media.GeometryHitTestResult
Protected Overridable Function HitTestCore (hitTestParameters As GeometryHitTestParameters) As GeometryHitTestResult

参数

hitTestParameters
GeometryHitTestParameters

GeometryHitTestParameters 对象,指定 Geometry 针对命中测试。

返回

GeometryHitTestResult

表示命中测试结果的 GeometryHitTestResult 对象。

示例

下面的示例演示如何重写 HitTestCore(GeometryHitTestParameters) 方法。 你可能想要替代此方法的一个原因是在命中测试过程中提供其他功能。

// Override default hit test support in visual object.
protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
{
    IntersectionDetail intersectionDetail = IntersectionDetail.NotCalculated;

    // Perform custom actions during the hit test processing.

    return new GeometryHitTestResult(this, intersectionDetail);
}
' Override default hit test support in visual object.
Protected Overrides Overloads Function HitTestCore(ByVal hitTestParameters As GeometryHitTestParameters) As GeometryHitTestResult
    Dim intersectionDetail As IntersectionDetail = IntersectionDetail.NotCalculated

    ' Perform custom actions during the hit test processing.

    Return New GeometryHitTestResult(Me, intersectionDetail)
End Function

注解

可以通过重写 HitTestCore 方法替代对视觉对象的默认命中测试支持。 这意味着调用 HitTest 该方法时,将调用重写的 HitTestCore 实现。 当命中测试位于视觉对象的边界矩形内时,将调用重写的方法,即使坐标位于视觉对象的几何图形之外也是如此。

适用于

HitTestCore(PointHitTestParameters)

确定点坐标值是否在可视对象的边界内。

protected:
 virtual System::Windows::Media::HitTestResult ^ HitTestCore(System::Windows::Media::PointHitTestParameters ^ hitTestParameters);
protected virtual System.Windows.Media.HitTestResult HitTestCore (System.Windows.Media.PointHitTestParameters hitTestParameters);
abstract member HitTestCore : System.Windows.Media.PointHitTestParameters -> System.Windows.Media.HitTestResult
override this.HitTestCore : System.Windows.Media.PointHitTestParameters -> System.Windows.Media.HitTestResult
Protected Overridable Function HitTestCore (hitTestParameters As PointHitTestParameters) As HitTestResult

参数

hitTestParameters
PointHitTestParameters

PointHitTestParameters 对象,指定 Point 针对命中测试。

返回

HitTestResult

表示从命中测试中返回的 HitTestResultVisual

示例

下面的示例演示如何重写 HitTestCore(PointHitTestParameters) 方法。 你可能想要替代此方法的一个原因是在命中测试过程中提供其他功能。

// Override default hit test support in visual object.
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
    Point pt = hitTestParameters.HitPoint;

    // Perform custom actions during the hit test processing,
    // which may include verifying that the point actually
    // falls within the rendered content of the visual.

    // Return hit on bounding rectangle of visual object.
    return new PointHitTestResult(this, pt);
}
' Override default hit test support in visual object.
Protected Overrides Overloads Function HitTestCore(ByVal hitTestParameters As PointHitTestParameters) As HitTestResult
    Dim pt As Point = hitTestParameters.HitPoint

    ' Perform custom actions during the hit test processing,
    ' which may include verifying that the point actually
    ' falls within the rendered content of the visual.

    ' Return hit on bounding rectangle of visual object.
    Return New PointHitTestResult(Me, pt)
End Function

注解

可以通过重写 HitTestCore 方法替代对视觉对象的默认命中测试支持。 这意味着调用 HitTest 该方法时,将调用重写的 HitTestCore 实现。 当命中测试位于视觉对象的边界矩形内时,将调用重写的方法,即使坐标位于视觉对象的几何图形之外也是如此。

适用于