对不起,设法确保包含所有信息!通用,可绑定,均匀拉伸布局
我需要的细胞图(VM对应一个视图)几乎像这样一个循环:
********
**********
************
**************
**************
**************
**************
************
**********
********
一些并发症: 之前,我们火了,我不知道有多少细胞显示。所有单元必须大小相等。整个视图必须可扩展。
在我的简化世界中,我的窗口创建了20个RowViewModel对象,并为每个构造函数传递它应创建的列数。
我的主要观点:
<Viewbox Stretch="Uniform">
<ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=Rows}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="{Binding Path=Rows.Count}" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Viewbox>
而且我RowView:
<Grid>
<ItemsControl ItemsSource="{Binding Columns}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding Columns.Count}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
我的手机的看法:
<Border >
<Viewbox Stretch="Uniform" >
<Label FontSize="10" Content="{Binding Notice}" Foreground="White" />
</Viewbox>
</Border>
目前的情况是,所有的行都是一样的宽度,使与行更少的细胞有更宽的细胞。如果我告诉每行有20个单元格,每个单元格都是相同的大小,但尽管使用了HorizontalAlignment设置,但所有单元格都保持一致,大概是因为它附加了空白单元格。我假设我可以在我想要的位置插入空白单元格,但这感觉就像是数据的巧妙结合,使显示正确,我相信您会同意B-A-D。
我已经尝试了数以万计的方法,并认为这是迄今为止最接近的,但我错过了它。你能帮忙吗?
感谢您的耐心等待。