This documentation is archived and is not being maintained.

Stroke.HitTest Method (Rect, Int32)

Returns a value that indicates whether the Stroke is within the bounds of the specified rectangle.

Namespace: System.Windows.Ink
Assembly: PresentationCore (in presentationcore.dll)

public bool HitTest (
	Rect bounds,
	int percentageWithinBounds
public boolean HitTest (
	Rect bounds, 
	int percentageWithinBounds
public function HitTest (
	bounds : Rect, 
	percentageWithinBounds : int
) : boolean
You cannot use methods in XAML.



A Rect that represents the bounds of the area to hit test.


The percentage of the length of the Stroke, that must be in percentageWithinBounds for the Stroke to be considered hit..

Return Value

true if the current stroke is within the bounds of bounds; otherwise false.

The following example makes a stroke purple if at least 80% of the stroke is within the Rect.

Rect rect1 = new Rect(100, 100, 100, 100);

if (aStroke.HitTest(rect1, 80))
    aStroke.DrawingAttributes.Color = Colors.Purple;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0