This documentation is archived and is not being maintained.

Visual.HitTestCore Method (GeometryHitTestParameters)

Determines whether a geometry value is within the bounds of the visual object.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

protected virtual GeometryHitTestResult HitTestCore(
	GeometryHitTestParameters hitTestParameters
)

Parameters

hitTestParameters
Type: System.Windows.Media.GeometryHitTestParameters
A GeometryHitTestParameters object that specifies the Geometry to hit test against.

Return Value

Type: System.Windows.Media.GeometryHitTestResult
A GeometryHitTestResult that represents the result of the hit test.

You can override default hit testing support for a visual object by overriding the HitTestCore method. 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.

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);
}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: