共用方式為


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

HitTestResult,表示從點擊測試傳回的 Visual

範例

以下範例將說明如何覆寫 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 。 當點擊測試落在視覺物件的周框內時,會呼叫覆寫的方法,即使座標落在視覺物件的幾何之外也一樣。

適用於