3

当第一行被占用时,如何让图片转到下一行?

以下是我当前的代码:

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

1 回答 1

6

使用 aWrapPanel而不是StackPanel. 由于 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>
于 2013-02-01T10:41:40.517 回答