ListBoxItem.Selected Event

 

Occurs when a ListBoxItem is selected.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

Public Event Selected As RoutedEventHandler

To know when the selection in a ListBox changes, listen for the SelectionChanged event.

Identifier field

SelectedEvent

Routing strategy

Bubbling

Delegate

RoutedEventHandler

The following example shows how to subscribe to and handle this event.

<ListBoxItem Name="lbi0" Selected="OnSelected" Unselected="OnUnselected">Item 0</ListBoxItem>
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

.NET Framework
Available since 3.0
Return to top
Show: