Is there are way to customize the listbox/listview horizontally and add items (images) coming from a database which has a record of image file paths?
views:
277answers:
1
+2
A:
Sure, just define a custom ItemTemplate for the listbox to show the image. Also override ItemsPanel to make it horizontal.
<ListBox ItemsSource={Binding CollectionOfFilePaths}>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox>
Then in codebehind:
ObservableCollection<string> CollectionOfFilePaths{get;set;}
//....
CollectionOfFilePaths= new ObservableCollection<string>{"c:\filepath1.jpg","c:\filepath1.jpg"};
Igor Zevaka
2010-05-06 05:34:12
Should be CollectionOfFilePaths in code behind, not or ;-)
jeffora
2010-05-06 06:31:18
Fat fingers + Cold = One of those real painful Data Binding errors that's not evident until runtime. Thanks for pointing it out.
Igor Zevaka
2010-05-06 06:33:17