Presenting Data with the ListBox Control

The ListBox control enables listing a series of items. The good news is that you are not limited to text items but 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:

<ListBox Name="ListBox1">    <ListBoxItem Content="Item 1"/>    <ListBoxItem Content="Item 2"/>    <!-- Creating a complex item,         with text and picture -->    <ListBoxItem>        <ListBoxItem.Content>            <StackPanel>                <TextBlock Text="Item 3 with image"/>                <Image Source="MyImage.jpg" />            </StackPanel>        </ListBoxItem.Content>    </ListBoxItem> ...

Get Visual Basic 2015 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.