如何在WPF中将一维ObservableCollection显示为矩阵?

时间:2012-10-14 18:13:53

标签: wpf

我有一个一维的ObservableCollection。如何将其显示为多维集合(Matrix)?

例如:我有要显示的图像列表(网址),因此连续三个图像和count / 3的行数等于。

我找到了如何将二维列表绑定到网格,但没有像我想要的那样。

这可能吗?

1 个答案:

答案 0 :(得分:0)

是的,您可以通过overriding ItemsPanelItemsControl这样做 -

<ItemsControl>
   <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
         <UniformGrid Rows="3" Columns="3"/>
      </ItemsPanelTemplate>
   </ItemsControl.ItemsPanel>
</ItemsControl>