StrokeCollection.Replace Method (Stroke, StrokeCollection)


Replaces the specified Stroke with the specified StrokeCollection.

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

Public Sub Replace (
	strokeToReplace As Stroke,
	strokesToReplaceWith As StrokeCollection


Type: System.Windows.Ink.Stroke

The Stroke to replace.

Type: System.Windows.Ink.StrokeCollection

The source StrokeCollection.

Exception Condition

strokesToReplace is empty.


strokesToReplaceWith is empty.


A Stroke in strokesToReplaceWith is already in strokesToReplace.

The Replace method raises the StrokesChanged event.

The following example demonstrates how to replace the selected strokes on an InkCanvas with another StrokeCollection. This example assumes that there is an InkCanvas called inkCanvas1.

' Replace the selected strokes with other strokes.
Private Sub ReplaceStrokes(ByVal strokes As StrokeCollection)

    Dim selectedStrokes As StrokeCollection = inkCanvas1.GetSelectedStrokes()

    If Not (selectedStrokes Is Nothing) Then
        inkCanvas1.Strokes.Replace(selectedStrokes, strokes)
    End If

End Sub

.NET Framework
Available since 3.0
Return to top