StrokeCollection.Replace 方法

定义

替换集合中的笔画。

重载

Replace(Stroke, StrokeCollection)

将指定的 Stroke 替换为指定的 StrokeCollection

Replace(StrokeCollection, StrokeCollection)

将指定的 StrokeCollection 替换为新的 StrokeCollection

Replace(Stroke, StrokeCollection)

将指定的 Stroke 替换为指定的 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)

参数

strokeToReplace
Stroke

要替换的 Stroke

strokesToReplaceWith
StrokeCollection

StrokeCollection

例外

strokesToReplace 为空。

- 或 -

strokesToReplaceWith 为空。

- 或 -

strokesToReplaceWith 中的 Stroke 已存在于 strokesToReplace 中。

示例

以下示例演示如何将 上的 InkCanvas 所选笔划替换为另一个 StrokeCollection。 此示例假定有一个名为 InkCanvasinkCanvas1

// 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

注解

Replace 方法引发 StrokesChanged 事件。

适用于

Replace(StrokeCollection, StrokeCollection)

将指定的 StrokeCollection 替换为新的 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)

参数

strokesToReplace
StrokeCollection

目标 StrokeCollection

strokesToReplaceWith
StrokeCollection

StrokeCollection

例外

strokesToReplace 为空。

- 或 -

strokesToReplaceWith 为空。

- 或 -

strokesToReplaceWith 中的 Stroke 已存在于 strokesToReplace 中。

- 或 -

strokesToReplaceWith 中的笔画不是连续的。

示例

以下示例演示如何将 上的 InkCanvas 所选笔划替换为另一个 StrokeCollection。 此示例假定有一个名为 InkCanvasinkCanvas1

// 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

注解

方法Replace会为其替换的每个Stroke引发 StrokesChanged 事件。

适用于