Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
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.
Example
<Canvas.Resources>
<ObjectDataProvider x:Key="Colors" ObjectType="{x:Type src:myColors}"/>
</Canvas.Resources>
...
<ListBox Name="myListBox" HorizontalAlignment="Left" SelectionMode="Extended"
Width="265" Height="55" Background="HoneyDew"
ItemsSource="{Binding Source={StaticResource Colors}}" IsSynchronizedWithCurrentItem="true">
</ListBox>
For the complete see List Box Sample.