แก้ไข

แชร์ผ่าน


StrokeCollection.Replace Method

Definition

Replaces the strokes in the collection.

Overloads

Replace(Stroke, StrokeCollection)

Replaces the specified Stroke with the specified StrokeCollection.

Replace(StrokeCollection, StrokeCollection)

Replaces the specified StrokeCollection with a new StrokeCollection.

Replace(Stroke, StrokeCollection)

Replaces the specified Stroke with the specified StrokeCollection.

public:
 void Replace(System::Windows::Ink::Stroke ^ strokeToReplace, System::Windows::Ink::StrokeCollection ^ strokesToReplaceWith);
public void Replace (System.Windows.Ink.Stroke strokeToReplace, System.Windows.Ink.StrokeCollection strokesToReplaceWith);
member this.Replace : System.Windows.Ink.Stroke * System.Windows.Ink.StrokeCollection -> unit
Public Sub Replace (strokeToReplace As Stroke, strokesToReplaceWith As StrokeCollection)

Parameters

strokeToReplace
Stroke

The Stroke to replace.

strokesToReplaceWith
StrokeCollection

The source StrokeCollection.

Exceptions

strokesToReplace is empty.

-or-

strokesToReplaceWith is empty.

-or-

A Stroke in strokesToReplaceWith is already in strokesToReplace.

Examples

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);
    }
}
' 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

Remarks

The Replace method raises the StrokesChanged event.

Applies to

Replace(StrokeCollection, StrokeCollection)

Replaces the specified StrokeCollection with a new StrokeCollection.

public:
 void Replace(System::Windows::Ink::StrokeCollection ^ strokesToReplace, System::Windows::Ink::StrokeCollection ^ strokesToReplaceWith);
public void Replace (System.Windows.Ink.StrokeCollection strokesToReplace, System.Windows.Ink.StrokeCollection strokesToReplaceWith);
member this.Replace : System.Windows.Ink.StrokeCollection * System.Windows.Ink.StrokeCollection -> unit
Public Sub Replace (strokesToReplace As StrokeCollection, strokesToReplaceWith As StrokeCollection)

Parameters

strokesToReplace
StrokeCollection

The destination StrokeCollection.

strokesToReplaceWith
StrokeCollection

The source StrokeCollection.

Exceptions

strokesToReplace is empty.

-or-

strokesToReplaceWith is empty.

-or-

A Stroke in strokesToReplaceWith is already in strokesToReplace.

-or-

The strokes in strokesToReplaceWith are not continuous.

Examples

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);
    }
}
' 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

Remarks

The Replace method raises the StrokesChanged event for each Stroke it replaces.

Applies to