This documentation is archived and is not being maintained.

StrokeCollection.Replace Method (Stroke, StrokeCollection)

Replaces the specified Stroke with the specified strokes.

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

public void Replace (
	Stroke strokeToReplace,
	StrokeCollection strokesToReplaceWith
)
public void Replace (
	Stroke strokeToReplace, 
	StrokeCollection strokesToReplaceWith
)
public function Replace (
	strokeToReplace : Stroke, 
	strokesToReplaceWith : StrokeCollection
)
You cannot use methods in XAML.

Parameters

strokeToReplace

The Stroke to replace.

strokesToReplaceWith

The source StrokeCollection.

Exception typeCondition

ArgumentException

strokesToReplace is empty.

-or-

strokesToReplaceWith is empty.

-or-

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 void ReplaceStrokes(StrokeCollection strokes)
{
    StrokeCollection selectedStrokes = inkCanvas1.GetSelectedStrokes();

    if (selectedStrokes != null && selectedStrokes.Count > 0)
    {
        inkCanvas1.Strokes.Replace(selectedStrokes, strokes);
    }
}

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
Show: