Presenting Data with the ListBox Control
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> ...