当前位置: 代码迷 >> Windows Mobile >> 怎样实现一个Grid样式的ListBox,该如何解决
  详细解决方案

怎样实现一个Grid样式的ListBox,该如何解决

热度:54   发布时间:2016-04-25 07:44:01.0
怎样实现一个Grid样式的ListBox
现在的视图是这样的:
item1
item2
item3
item4
item5
item6

我想做成这样的:
item1 item2
item3 item4
item5 item6

------解决方案--------------------
WrapPanel
用这个控件
在toolkit里面的
自己应该会添加吧
------解决方案--------------------
用WrapPanel
实现自动折行!

 <ListBox Name="ListChannel" Margin="0,-50,10,0" ItemsSource="{Binding ChannelList}" Height="530" SelectedIndex="{Binding ChannelliIndex,Mode=TwoWay}" Foreground="{StaticResource WhiteBrushKey}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Width="400" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>

<Grid Margin="5,0,5,10" Width="180">
<Rectangle Width="172" Height="172" Fill="#FF830F49"></Rectangle>
<Image Height="172" Width="172" Source="{Binding ImgUrl}" Margin="0,10,0,0" />
<TextBlock Text="{Binding nodeName}" HorizontalAlignment="Center" TextWrapping="NoWrap" FontSize="22" Margin="50,130,50,0" />
</Grid>

</DataTemplate>
</ItemsControl.ItemTemplate>

</ListBox>
  相关解决方案