【发布时间】:2010-05-06 05:19:34
【问题描述】:
【问题讨论】:
标签: wpf filepath listboxitem horizontallist
【问题讨论】:
标签: wpf filepath listboxitem horizontallist
当然,只需为列表框定义一个自定义 ItemTemplate 即可显示图像。同时覆盖 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"};
【讨论】: