ListBox following line automatically in Windows Phone 8

How can I go to the next line when the first line is busy?

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>

      

+3


source to share


1 answer


Use WrapPanel

instead StackPanel

. Since Windows Phone 8 does not provide a control WrapPanel

, 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>

      

+6


source







All Articles