Reputation: 2541
Im trying to bind a list of images to a Listbox, but all I get is a list of Type names
<ListBox x:Name="PhotosListBox" ItemsSource="{Binding MyImages}" />
The MyImages is a List<BitMapImages>
Right now It just returns a list of System.Windows.Media.Imaging.BitmapImage
instead of showing the Images
EDIT For further ref, here is the final code.
<ListBox x:Name="PhotosListBox" ItemsSource="{Binding MyImages}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Stretch="Uniform"></Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Upvotes: 2
Views: 2498
Reputation: 504
You need to use an ItemTemplate
other than the default so that the ListBox
knows how to handle the data type being passed to it.
See: http://msdn.microsoft.com/en-us/library/ms742521.aspx
Upvotes: 3
Reputation: 34349
By default, the ToString()
method of the bound data type will be invoked, which by default will return the fully qualified type name.
You should define a custom ItemTemplate for the ListBox.
Upvotes: 3