SurfaceInkCanvas.Strokes Property

Gets or sets the collection of ink strokes that a SurfaceInkCanvas object collects.

Namespace: Microsoft.Surface.Presentation.Controls
Assembly: Microsoft.Surface.Presentation (in Microsoft.Surface.Presentation)


public StrokeCollection Strokes { get; set; }
/** @property */
public StrokeCollection get_Strokes ()

/** @property */
public void set_Strokes (StrokeCollection value)

public function get Strokes () : StrokeCollection

public function set Strokes (value : StrokeCollection)

Property Value

Returns StrokeCollection.

The following code examples implement a simple undo system to undo erased strokes. During application initialization, a generic Stack collection is instantiated. This collection will hold the erased Stroke objects until the user accesses the undo operation.

private Stack<Stroke> erasedStrokes = new Stack<Stroke>();

When the StrokeErasing event is raised, the event handler checks to see if another handler has canceled the event. If not, the Stroke object is pushed on the stack.

private void InkCanvas_StrokeErasing(object sender, SurfaceInkCanvasStrokeErasingEventArgs e)
    if (!e.Cancel)

When the user clicks the undo button, the stack is checked to see if it is empty. If not, a Stroke object is removed from the stack and added to the Strokes collection of the SurfaceInkCanvas control.

private void SurfaceButtonUndo_Click(object sender, System.Windows.RoutedEventArgs e)
    if (erasedStrokes.Count > 0)
        Stroke stroke = erasedStrokes.Pop();

The Strokes property is a dependency property that is identified by the StrokesProperty field.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



Operating System (OS)Windows 7
Software Developer Kit (SDK)Surface 2.0
.NET Framework 4
Developer environmentVisual Studio 2010, Express or full edition
Microsoft Expression Blend 4.0 (optional)
End-user hardwareDevices made for Surface 2.0, or
Windows Touch computers

Did you find this information useful? Please send us your suggestions and comments.

© Microsoft Corporation. All rights reserved.