xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:ListBoxEvent" x:Class="ListBoxEvent.Pane1">
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
//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
Imports System.Windows.Media
Imports System.Collections.ObjectModel
Namespace ListBoxEvent
Public Class myColors
Inherits ObservableCollection(Of String)
Public Sub New()
Add("A")
Add("B")
Add("C")
Add("D")
Add("E")
Add("F")
End Sub
End Class
Public Partial Class Pane1
Inherits Canvas
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Private Sub PrintText(sender As Object, args As SelectionChangedEventArgs)
Dim lbi As ListBoxItem = TryCast(TryCast(sender, ListBox).SelectedItem, ListBoxItem)
tb.Text = " You selected " & lbi.Content.ToString() & "."
End Sub
End Class
End Namespace