在WPF中,显示图像网格的正确方法是什么?

时间:2017-03-08 11:09:29

标签: c# wpf

我试图制作一个基本的瓷砖地图edior,我想在某种网格中显示加载的瓷砖组中的每个瓷砖,以便在同一行上添加新的瓷砖,直到该行为满,并且然后开始填写下一行。我添加了一张图片,以便更好地说明我的内容:

enter image description here

我应该使用某种类型的修改后的ListView,还是画布?包含瓷砖的面板是可以接受的,我希望瓷砖能够重新排列,具体取决于面板的尺寸。

1 个答案:

答案 0 :(得分:1)

您可以使用ItemsControl UniformGrid作为ItemsTemplate之类的<{p>}来实现此目标

<ItemsControl ItemsSource="{Binding Items}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <!-- Present your item here -->
        </DataTemplate>
    </ItemsControl.Itemtemplate>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Columns="5"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>
相关问题