Selector.Selected 附加事件

定義

當項目選取時發生。Occurs when an item is selected.

see AddSelectedHandler, and RemoveSelectedHandler
see AddSelectedHandler, and RemoveSelectedHandler
see AddSelectedHandler, and RemoveSelectedHandler

範例

下列範例示範如何使用 Selected 事件搭配 @no__t 1 控制項。The following examples show how to use the Selected event with a ListBox control. 第一個範例會引發事件,第二個則顯示如何處理事件。The first example raises the event and the second shows how to handle the event.

<ListBoxItem Name="lbi0" Selected="OnSelected" Unselected="OnUnselected">
     Item 0</ListBoxItem>
private void OnSelected(object sender, RoutedEventArgs e)
{
    Item.Content = ((ListBoxItem)sender).Name + " was selected.";
}
Private Sub OnSelected(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Item.Content = (CType(sender, ListBoxItem)).Name & " was selected."
End Sub

備註

路由事件資訊Routed Event Information

識別碼欄位Identifier field SelectedEvent
路由策略Routing strategy 路由Bubbling
Delegate - 委派Delegate RoutedEventHandler

適用於