ListBoxItem.Selected 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生在選取 ListBoxItem 時。
public:
event System::Windows::RoutedEventHandler ^ Selected;
public event System.Windows.RoutedEventHandler Selected;
member this.Selected : System.Windows.RoutedEventHandler
Public Custom Event Selected As RoutedEventHandler
事件類型
範例
下列範例示範如何訂閱及處理此事件。
<ListBoxItem Name="lbi0" Selected="OnSelected" Unselected="OnUnselected">Item 0</ListBoxItem>
private void OnSelected(object sender, RoutedEventArgs e)
{
ListBoxItem lbi = e.Source as ListBoxItem;
if (lbi != null)
{
label1.Content = lbi.Content.ToString() + " is selected.";
}
}
Private Sub OnSelected(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim lbi As ListBoxItem = TryCast(e.Source, ListBoxItem)
If lbi IsNot Nothing Then
label1.Content = lbi.Content.ToString() & " is selected."
End If
End Sub
備註
若要知道選取 ListBox 專案何時變更,請接 SelectionChanged 聽 事件。
路由事件資訊
識別碼欄位 | SelectedEvent |
路由策略 | 鼓 泡 |
代理人 | RoutedEventHandler |