如何在 WP8 ListBox 中使用水平方向? [英] How to use Horizontal Orientation in WP8 ListBox?

查看:28
本文介绍了如何在 WP8 ListBox 中使用水平方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下 xaml 代码来水平显示列表,

I'm using the following xaml code to display a list horizontally,

<ListBox x:Name="List" HorizontalAlignment="Left" Height="429" Margin="18,83,0,0" VerticalAlignment="Top" Width="424" SelectionChanged="List_SelectionChanged_1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                        <StackPanel Orientation="Horizontal" Width="420" Height="80">
                            <TextBox x:Name="tbName" IsHitTestVisible="False" Height="70" Background="Green" Foreground="White" FontSize="22" BorderThickness="0" Text="{Binding Name}" />
                        </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

我真正想要的是:
 在 TextBlock 越过宽度后,它应该放在下一行(通常应该像我们在纸上写的那样).
IE .在到达 StackPanel 的末尾之前,我们将水平附加 TextBox,但是在到达 StackPanel 的末尾之后,我们将放置下一个TextBox 在下一行).

What I want exactly is:
 after the TextBlock crosses the width it should be placed in the next line (Typically it should be like how we write in a paper).
i.e . until we reach the end of the StackPanel we will append the TextBox horizontally, but after the end of the StackPanel is reached we will place the next TextBox in the next line).

我该怎么做??

推荐答案

尝试将此代码添加到您的列表框中:

try to add this code in your listBox:

<ListBox.ItemsPanel>
   <ItemsPanelTemplate>
       <StackPanel Orientation="Horizontal"/>
   </ItemsPanelTemplate>
</ListBox.ItemsPanel>

项目的方向取决于 ItemsPanel.

the oriention of items depends on ItemsPanel.

这篇关于如何在 WP8 ListBox 中使用水平方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆