Visual.HitTestCore Visual.HitTestCore Visual.HitTestCore Visual.HitTestCore Method

定義

判斷點或幾何值是否在視覺物件的界限中。Determines whether a point or geometry value is within the bounds of the visual object.

多載

HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters)

判斷幾何值是否在視覺物件的界限中。Determines whether a geometry value is within the bounds of the visual object.

HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters)

判斷點座標值是否在視覺物件的界限中。Determines whether a point coordinate value is within the bounds of the visual object.

HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters)

判斷幾何值是否在視覺物件的界限中。Determines whether a geometry value is within the bounds of the visual object.

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 GeometryHitTestParameters GeometryHitTestParameters

GeometryHitTestParameters 物件,指定要進行點擊測試的 GeometryA GeometryHitTestParameters object that specifies the Geometry to hit test against.

傳回

範例

以下範例將說明如何覆寫 HitTestCore(GeometryHitTestParameters) 方法。The following example shows how to override the HitTestCore(GeometryHitTestParameters) method. 您可能想要覆寫這個方法的其中一個原因是在點擊測試的程序期間提供額外的功能。One reason you might want to override this method is to provide additional functionality during the hit testing process.

// 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方法。You can override default hit testing support for a visual object by overriding the HitTestCore method. 這表示,當您叫用HitTest方法中的覆寫實的作HitTestCore呼叫。This means that when you invoke the HitTest method, your overridden implementation of HitTestCore is called. 即使座標落在視覺物件的幾何以外時點擊的測試落在視覺物件的週框矩形內會呼叫您覆寫的方法。Your overridden method is called when a hit test falls within the bounding rectangle of the visual object, even if the coordinate falls outside the geometry of the visual object.

HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters)

判斷點座標值是否在視覺物件的界限中。Determines whether a point coordinate value is within the bounds of the visual object.

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 PointHitTestParameters PointHitTestParameters

PointHitTestParameters 物件,指定要進行點擊測試的 PointA PointHitTestParameters object that specifies the Point to hit test against.

傳回

HitTestResult,表示從點擊測試傳回的 VisualA HitTestResult that represents the Visual that is returned from a hit test.

範例

以下範例將說明如何覆寫 HitTestCore(PointHitTestParameters) 方法。The following example shows how to override the HitTestCore(PointHitTestParameters) method. 您可能想要覆寫這個方法的其中一個原因是在點擊測試的程序期間提供額外的功能。One reason you might want to override this method is to provide additional functionality during the hit testing process.

// 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方法。You can override the default hit testing support on visual objects by overriding the HitTestCore method. 這表示,當您叫用HitTest方法中的覆寫實的作HitTestCore呼叫。This means that when you invoke the HitTest method, your overridden implementation of HitTestCore is called. 即使座標落在視覺物件的幾何以外時點擊的測試落在視覺物件的週框矩形內會呼叫您覆寫的方法。Your overridden method is called when a hit test falls within the bounding rectangle of the visual object, even if the coordinate falls outside the geometry of the visual object.

適用於