Visual.HitTestCore Method (PointHitTestParameters)

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

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

protected virtual HitTestResult HitTestCore(
	PointHitTestParameters hitTestParameters
)
You cannot use methods in XAML.

Parameters

hitTestParameters
Type: System.Windows.Media.PointHitTestParameters

A PointHitTestParameters object that specifies the Point to hit test against.

Return Value

Type: System.Windows.Media.HitTestResult
A HitTestResult that represents the Visual that is returned from a hit test.

You can override the default hit testing support on visual objects 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(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);
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft