[英]ListBox next line automatically in Windows Phone 8
How can I have the pictures go to next line when the first line is occupied? 当第一行被占用时,如何将图片转到下一行?
Below is my current code: 以下是我目前的代码:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Picture" Style="{StaticResource PhoneTextNormalStyle}"/>
<ListBox x:Name="picList" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Picture}" Height="80" Width="80"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Use a WrapPanel
instead of the StackPanel
. 使用
WrapPanel
而不是StackPanel
。 As Windows Phone 8 does not provide for a WrapPanel
control, you need to use the Windows Phone Toolkit . 由于Windows Phone 8不提供
WrapPanel
控件,因此您需要使用Windows Phone Toolkit 。
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Picture" Style="{StaticResource PhoneTextNormalStyle}"/>
<ListBox x:Name="picList" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"
Width="300"
HorizontalAlignment="Left"
/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Picture}" Height="80" Width="80"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.