InkCanvas.StrokesReplaced Event

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Occurs when the Strokes property is replaced.

C#
public event System.Windows.Controls.InkCanvasStrokesReplacedEventHandler StrokesReplaced;

Event Type

Examples

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.

C#
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";
    }
}

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10