我有一个需要以以下方式显示的动态数据列表:
1 4 7 10
2 5 8 11
3 6 9 12
13 16 19 22
14 17 20 23
15 18 21 24
...但是,我的代码只迭代顶部,并在屏幕之外运行。下面的代码位于网格内部。我做错了什么?
<toolkit:WrapPanel Orientation="Vertical" Grid.Row="2" >
<ItemsControl ItemsSource="{Binding ImagingTypes, Mode=TwoWay}"
Margin="5">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,0,5,0">
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" VerticalAlignment="Top" />
<TextBlock Grid.Column="1" Text="{Binding Description}" MaxWidth="150" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</toolkit:WrapPanel>发布于 2014-11-13 03:05:41
对不起,我不太懂英语,所以我不能确切的理解你的mean.But是什么,如果你想要上面的序列,如果你想保持items.You的位置不变,可以使用UniformGrid。我希望这就是你要找的。
下面是代码:
我做了一个列表视图示例;
<ListView x:Name="SharedSizeScopeListView">
<ListView.ItemsPanel>
<ItemsPanelTemplate >
<UniformGrid IsItemsHost="True" Columns="4"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListViewItem Content="1"/>
<ListViewItem Content="4"/>
<ListViewItem Content="7"/>
<ListViewItem Content="10"/>
<ListViewItem Content="2"/>
<ListViewItem Content="5"/>
<ListViewItem Content="8"/>
<ListViewItem Content="11"/>
<ListViewItem Content="3"/>
<ListViewItem Content="6"/>
<ListViewItem Content="9"/>
<ListViewItem Content="12"/>
<ListViewItem Content="13"/>
<ListViewItem Content="16"/>
<ListViewItem Content="19"/>
<ListViewItem Content="22"/>
<ListViewItem Content="14"/>
<ListViewItem Content="17"/>
<ListViewItem Content="20"/>
<ListViewItem Content="23"/>
<ListViewItem Content="15"/>
<ListViewItem Content="18"/>
<ListViewItem Content="21"/>
<ListViewItem Content="24"/>
</ListView>发布于 2014-11-13 05:48:30
我不认为WrapPanel支持这种分层包装。嵌套方法不起作用--内侧面板无法将其“遗留”项“转发”到外侧面板。
最简单的方法取决于您是想要固定的列数,还是想适合容器的大小。如果是前者,则可以使用Grid并连续填充其单元格(使用代码隐藏或行为),即(0,0),(0,1),(0,2),(1,0),...,(0,4),(0,5),(0,6),(1,4),...
如果是后者--您希望继续水平布局项目,直到空间耗尽--那么可能需要一个custom Panel。编写自己的面板有一点学习曲线(您必须阅读Silverlight布局系统),但它为您提供了很大的灵活性。
https://stackoverflow.com/questions/26891458
复制相似问题