//File:Window.xaml.vb Imports System Imports System.ComponentModel Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Documents Imports System.Windows.Navigation Imports System.Windows.Shapes Imports System.Windows.Data Namespace ListBox_Index Public Partial Class Window1 Inherits Window Public Sub New() InitializeComponent() End Sub Private Sub PrintText(sender As Object, args As SelectionChangedEventArgs) Dim lbi As ListBoxItem = TryCast(TryCast(sender, ListBox).SelectedItem, ListBoxItem) If lbi Is Nothing Then Return End If label1.Content = "You chose " & lbi.Content.ToString() & "." End Sub End Class End Namespace