ListBox

The ListBox control enables listing a series of items. The good news is that you are not limited to text items but you can also add complex items. Each item is represented by a ListBoxItem object, nested in the ListBox. The following example shows how you can declare a ListBox in XAML code:

image

Typically a ListBox is populated at runtime via data-binding. Basically concepts are the same as illustrated for the ComboBox control, so take a look there for a recap. To accomplish data-binding, simply specify the ItemsSource markup extension as follows:

<ListBox Name="ListBox1" ItemsSource="{Binding}"/>

Then in Visual Basic code you assign the

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.