Bagikan melalui


InkCanvas.SelectionChanging Kejadian

Definisi

Terjadi ketika sekumpulan goresan tinta dan/atau elemen baru sedang dipilih.

public:
 event System::Windows::Controls::InkCanvasSelectionChangingEventHandler ^ SelectionChanging;
public event System.Windows.Controls.InkCanvasSelectionChangingEventHandler SelectionChanging;
member this.SelectionChanging : System.Windows.Controls.InkCanvasSelectionChangingEventHandler 
Public Custom Event SelectionChanging As InkCanvasSelectionChangingEventHandler 
Public Event SelectionChanging As InkCanvasSelectionChangingEventHandler 

Jenis Acara

Contoh

Contoh berikut membuat goresan royal biru yang dipilih.

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;
        }
    }
}
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
        Else
            aStroke.DrawingAttributes.Color = inkCanvas1.DefaultDrawingAttributes.Color
        End If
    Next aStroke

End Sub

Keterangan

Peristiwa SelectionChanging dinaikkan ketika stroke dan/atau elemen dipilih oleh pengguna - tetapi sebelum perubahan diterapkan.

Peristiwa SelectionChanging diproses InkCanvasSelectionChangingEventArgs saat InkCanvasSelectionChangingEventHandler menerima objek. InkCanvasSelectionChangingEventArgs menyediakan metode untuk mengakses FrameworkElement dan StrokeCollection objek setelah dipilih oleh pengguna.

Setelah perubahan diterapkan, SelectionChanged peristiwa akan dimunculkan.

Catatan

Peristiwa SelectionChanging tidak terjadi ketika goresan yang dipilih dihapus atau ketika ActiveEditingMode properti berubah.

Berlaku untuk

Lihat juga