共用方式為


InkCanvas.StrokesReplaced 事件

定義

Strokes 屬性被取代時,就會發生。

public:
 event System::Windows::Controls::InkCanvasStrokesReplacedEventHandler ^ StrokesReplaced;
public event System.Windows.Controls.InkCanvasStrokesReplacedEventHandler StrokesReplaced;
member this.StrokesReplaced : System.Windows.Controls.InkCanvasStrokesReplacedEventHandler 
Public Custom Event StrokesReplaced As InkCanvasStrokesReplacedEventHandler 
Public Event StrokesReplaced As InkCanvasStrokesReplacedEventHandler 

事件類型

範例

下列範例示範如何使用位於相同 InkCanvas 上的兩 StrokeCollection 個 物件。 在此範例中,玩家一和玩家兩個都會使用個別的「筆跡表面」,即使它們共用相同的 InkCanvas 。 此範例假設 switchPlayersButton_Click 事件已連線到事件處理常式。

StrokeCollection player1;
StrokeCollection player2;

void InitializePlayersCanvases()
{
    player1 = inkCanvas1.Strokes;
    player2 = new StrokeCollection();
}

// Use a different "inking surface" for each player.
void switchPlayersButton_Click(object sender, RoutedEventArgs e)
{
    if (StrokeCollection.ReferenceEquals(inkCanvas1.Strokes, player1))
    {
        inkCanvas1.Strokes = player2;
    }
    else
    {
        inkCanvas1.Strokes = player1;
    }
}

void inkCanvas1_StrokesReplaced(object sender, InkCanvasStrokesReplacedEventArgs e)
{
    if (StrokeCollection.ReferenceEquals(e.NewStrokes, player1))
    {
        Title = "Player one's turn";
    }
    else
    {
        Title = "Player two's turn";
    }
}
Private player1 As StrokeCollection
Private player2 As StrokeCollection


Sub InitializePlayersCanvases()

    player1 = inkCanvas1.Strokes
    player2 = New StrokeCollection()

End Sub


' Use a different "inking surface" for each player.
Private Sub switchPlayersButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    If StrokeCollection.ReferenceEquals(inkCanvas1.Strokes, player1) Then
        inkCanvas1.Strokes = player2
    Else
        inkCanvas1.Strokes = player1
    End If

End Sub


Private Sub inkCanvas1_StrokesReplaced(ByVal sender As Object, _
                               ByVal e As InkCanvasStrokesReplacedEventArgs)

    If StrokeCollection.ReferenceEquals(e.NewStrokes, player1) Then
        Title = "Player one's turn"
    Else
        Title = "Player two's turn"
    End If

End Sub

適用於