ListBox next line automatically in Windows Phone 8
c#, windows-phone-8, xaml
Solution
Use a `WrapPanel` instead of the `StackPanel`. As Windows Phone 8 does not provide for a `WrapPanel` control, you need to use the 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>
Problem
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> ```