WPF/C#:如何通过(来自数据库表的文件路径)从水平列表框/listview添加图像
有没有办法横向定制listbox/listview并添加来自具有图像文件路径记录的数据库的项目(图像)WPF/C#:如何通过(来自数据库表的文件路径)从水平列表框/listview添加图像,wpf,filepath,listboxitem,horizontallist,Wpf,Filepath,Listboxitem,Horizontallist,有没有办法横向定制listbox/listview并添加来自具有图像文件路径记录的数据库的项目(图像) 当然,只需为列表框定义一个自定义项模板即可显示图像。同时覆盖ItemsPanel使其水平 <ListBox ItemsSource={Binding CollectionOfFilePaths}> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Hor
当然,只需为列表框定义一个自定义项模板即可显示图像。同时覆盖ItemsPanel使其水平
<ListBox ItemsSource={Binding CollectionOfFilePaths}>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox>
然后在代码隐藏中:
ObservableCollection<string> CollectionOfFilePaths{get;set;}
//....
CollectionOfFilePaths= new ObservableCollection<string>{"c:\filepath1.jpg","c:\filepath1.jpg"};
observeCollectionCollectionOfficePath{get;set;}
//....
CollectionOfficePaths=新的ObservableCollection{“c:\filepath1.jpg”,“c:\filepath1.jpg”};
Fat fingers+Cold=一个真正痛苦的数据绑定错误,直到运行时才会显现出来。谢谢你指出这一点。