1
我正在尝试执行我的第一个WPF项目,并且我已经开始使用this sample project进行图像显示。部分原因是结合一个列表框图像阵列的XAML:WPF:将ItemsSource绑定到目录
<ListBox.ItemsSource>
<x:Array Type="{x:Type ImageSource}">
<ImageSource>http://static.flickr.com/34/70703587_b35cf6d9eb.jpg</ImageSource>
<ImageSource>http://static.flickr.com/20/70703557_494d721b23.jpg</ImageSource>
<ImageSource>http://static.flickr.com/35/70703504_3ebf8f0150.jpg</ImageSource>
<ImageSource>http://static.flickr.com/35/70703474_18ef30450f.jpg</ImageSource>
</x:Array>
</ListBox.ItemsSource>
现在是不错,但我想将其绑定到所有图像的子文件夹,它是模式匹配的子文件夹。我的目录结构如下:
Archive
1994-01
Index.jpg
Page1.jpg
...
PageN.jpg
1994-02
Index.jpg
Page1.jpg
...
PageN.jpg
我想将Listbox绑定到各种Index.jpg图像上。
我通常的做法是使用System.IO和Directory.GetFiles来做一些CodeBehind,但由于XAML看起来相当强大,我只是想知道:这种绑定方式是否可以完全在XAML中实现?
如前所述,WPF中的初学者和我想要做到“正确”的方式,这似乎是DataBinding。