私は BitmapSources の ObservableCollection を持っており、それらをすべてグリッドに表示し、選択されたスタイルと選択されていないスタイルをオーバーライドしたいと考えています。これを行うためにさまざまな方法を検討してきましたが、満足のいくように機能させることができませんでした。私の最新の試みは次のようになります。
<ListBox ItemsSource={Binding Images}>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemsHost="True">
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="3">
<Image Source={Binding}>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
これは画像を表示しますが、WrapPanel は常に 1 行です... 水平方向にスクロールする必要はありません。行ごとのアイテムなど。WrapPanel がないと、画像はそれぞれ 1 行になります。また、DataTemplate の DataType が ListBoxItem ではなく BitmapSource になっているため、選択したアイテムなどのスタイルをオーバーライドする方法がよくわかりません...
同様の結果で DataGrid (より適切と思われる) も試しました。
どうすればいいですか?