InkCanvas.SelectionChanging 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
選取一組新的筆墨筆劃及/或項目之後,就會發生。
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
事件類型
範例
下列範例會讓選取的筆劃變成藍色。
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
備註
SelectionChanging當使用者選取筆劃和/或元素時,會在套用變更之前引發事件。
當 收到 InkCanvasSelectionChangingEventArgs 物件時 InkCanvasSelectionChangingEventHandler ,就會 SelectionChanging 處理事件。 InkCanvasSelectionChangingEventArgs 提供在使用者選取物件之後存取 FrameworkElement 和 StrokeCollection 物件的方法。
套用變更之後,就會 SelectionChanged 引發 事件。
注意
刪除 SelectionChanging 選取的筆劃或屬性變更時 ActiveEditingMode ,不會發生此事件。