Skip to main content
InkCanvasStrokesReplaced Event
 

Occurs when the property is replaced.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public event InkCanvasStrokesReplacedEventHandler StrokesReplaced
public:
event InkCanvasStrokesReplacedEventHandler^ StrokesReplaced {
	void add(InkCanvasStrokesReplacedEventHandler^ value);
	void remove(InkCanvasStrokesReplacedEventHandler^ value);
}
member StrokesReplaced : IEvent<InkCanvasStrokesReplacedEventHandler,
    InkCanvasStrokesReplacedEventArgs>
Public Event StrokesReplaced As InkCanvasStrokesReplacedEventHandler

The following example demonstrates how to use two StrokeCollection objects that are co-located on the same InkCanvas. In this example, player one and player two each use an individual "inking surface" even though they share the same InkCanvas. This example assumes that the switchPlayersButton_Click event is connected to the event handler.

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 'InitializePlayersCanvases


' 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 'switchPlayersButton_Click


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 'inkCanvas1_StrokesReplaced
.NET Framework
Available since 3.0
Return to top