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 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.