Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InkCanvas.SelectionChanging Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs when a new set of ink strokes and/or elements is being selected.

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

Public Event SelectionChanging As InkCanvasSelectionChangingEventHandler

The SelectionChanging event is raised when strokes and/or elements are selected by the user - but before the change is applied.

The SelectionChanging event is processed when the InkCanvasSelectionChangingEventHandler receives an InkCanvasSelectionChangingEventArgs object. InkCanvasSelectionChangingEventArgs provides methods for accessing FrameworkElement and StrokeCollection objects after they are selected by the user.

After the change is applied, the SelectionChanged event is raised.


The SelectionChanging event does not occur when the selected strokes are deleted or when the ActiveEditingMode property changes.

The following example makes selected strokes royal blue.

Private Sub inkCanvas1_SelectionChanging(ByVal sender As Object, _
                                 ByVal e As InkCanvasSelectionChangingEventArgs)

    Dim selectedStrokes As StrokeCollection = e.GetSelectedStrokes()

    Dim aStroke As Stroke
    For Each aStroke In inkCanvas1.Strokes
        If selectedStrokes.Contains(aStroke) Then
            aStroke.DrawingAttributes.Color = Colors.RoyalBlue
            aStroke.DrawingAttributes.Color = inkCanvas1.DefaultDrawingAttributes.Color
        End If
    Next aStroke

End Sub 'inkCanvas1_SelectionChanging

.NET Framework
Available since 3.0
Return to top
© 2018 Microsoft