Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Bind a ListBox to Data

An application developer can create ListBox controls without specifying the contents of each ListBoxItem separately. You can use data binding to bind data to the individual items.

The following example shows how to create a ListBox that populates the ListBoxItem elements by data binding to a data source called Colors. In this case it is not necessary to use ListBoxItem tags to specify the content of each item.

<Canvas.Resources>
  <src:myColors x:Key="Colors"/>
</Canvas.Resources>


...


<ListBox Name="myListBox" HorizontalAlignment="Left" SelectionMode="Extended" 
      Width="265" Height="55" Background="HoneyDew" SelectionChanged="myListBox_SelectionChanged"
      ItemsSource="{Binding Source={StaticResource Colors}}" IsSynchronizedWithCurrentItem="true">
</ListBox>
Show:
© 2015 Microsoft