This documentation is archived and is not being maintained.

InkCanvas.GetSelectedStrokes Method

Retrieves a StrokeCollection that represents the Stroke objects that are selected in the InkCanvas.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)

public StrokeCollection GetSelectedStrokes ()
public StrokeCollection GetSelectedStrokes ()
public function GetSelectedStrokes () : StrokeCollection
You cannot use methods in XAML.

Return Value

The collection that represents the selected strokes.

An InkCanvas can contain Stroke objects, which are created in response to user stylus input, and FrameworkElement objects, such as Image and Button objects. Using this method will return only strokes, not FrameworkElement objects. To retrieve selected FrameworkElement objects, call the GetSelectedElements method.

Both Stroke and FrameworkElement objects can be selected by the user while the EditingMode of InkCanvas is set to EditingMode, or in code by calling the Select method.

The following example changes the color of each selected stroke on an InkCanvas.

StrokeCollection selectedStrokes = inkCanvas1.GetSelectedStrokes();

foreach (Stroke aStroke in selectedStrokes)
    aStroke.DrawingAttributes.Color = Colors.Red;

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