共用方式為


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 。 此範例假設有 InkCanvas 名為 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

備註

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 。 此範例假設有 InkCanvas 名為 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

備註

方法 ReplaceStrokesChanged 會針對它所取代的每個 Stroke 引發 事件。

適用於