【问题标题】:ListBox next line automatically in Windows Phone 8在 Windows Phone 8 中自动列表框下一行
【发布时间】:2023-03-26 19:31:01
【问题描述】:

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

以下是我当前的代码:

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

【问题讨论】:

    标签: c# xaml windows-phone-8


    【解决方案1】:

    使用WrapPanel 而不是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>
    

    【讨论】:

    • WrapPanel 不存在。
    • 对不起,我没有看到你的问题被标记为 windows phone。您可以从 Windows Phone 工具包获取 WrapPanel:phone.codeplex.com
    猜你喜欢
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多