Windows Dev Center

Information
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

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

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public event InkCanvasSelectionChangingEventHandler SelectionChanging
/** @event */
public void add_SelectionChanging (InkCanvasSelectionChangingEventHandler value)

/** @event */
public void remove_SelectionChanging (InkCanvasSelectionChangingEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
<object SelectionChanging="InkCanvasSelectionChangingEventHandler" .../>

The SelectionChanging event is raised when a new selection of strokes and/or elements is made by the user and before the change is applied.

The SelectionChanging event is processed through the InkCanvasSelectionChangingEventHandler that receives an InkCanvasSelectionChangingEventArgs object. InkCanvasSelectionChangingEventArgs provides methods for accessing the user's selection of FrameworkElement and StrokeCollection objects.

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

NoteNote:

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.

void inkCanvas1_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
{
    StrokeCollection selectedStrokes = e.GetSelectedStrokes();
    
    foreach (Stroke aStroke in inkCanvas1.Strokes)
    {
        if (selectedStrokes.Contains(aStroke))
        {
            aStroke.DrawingAttributes.Color = Colors.RoyalBlue;
        }
        else
        {
            aStroke.DrawingAttributes.Color = inkCanvas1.DefaultDrawingAttributes.Color;
        }

    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2015 Microsoft