首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WrapPanel的使用

WrapPanel的使用
EN

Stack Overflow用户
提问于 2011-12-29 14:43:51
回答 1查看 188关注 0票数 0

我必须在堆栈面板中的文本块中包装内容。下面的XAML代码是

代码语言:javascript
复制
        <ListBox.ItemTemplate>

            <DataTemplate>

                    <StackPanel Width="300">

                    <Image Height="160" HorizontalAlignment="Left" Margin="0,0,-400,0"  VerticalAlignment="Top" Width="175" Source="{Binding thumb}"/>
                    <!--ContentControl Width="150" Height="110" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,0,-400,0" Content="{Binding Image}"/>-->
                    <TextBlock  TextWrapping="Wrap"  VerticalAlignment="Top" HorizontalAlignment="Left" Margin="190,-167,-200,0" Text="{Binding title}"/>
                    <TextBlock  TextWrapping="Wrap"  VerticalAlignment="Top" HorizontalAlignment="Left" Margin="190,-135,-200,0" Text="{Binding page}"/>


                    <TextBlock FontSize="15" TextWrapping="Wrap" Height="Auto" Margin="190,-95,-200,0" Text="{Binding Name}" />

                    </StackPanel>

            </DataTemplate>
        </ListBox.ItemTemplate    


   When i specify the width of the text block the text wrap works in the vertical and horizontal orientation.

           I want the text to wrap in the vertical view only and in the horizontal view the text should not wrap without mention the textblock width.

例如,在垂直视图中,列表框宽度较小,因此文本应为:

代码语言:javascript
复制
           match is between India and
           pakistan

在水平视图中..我需要它在一行中

比赛在印度和巴基斯坦之间进行。

提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2011-12-29 17:50:52

代码语言:javascript
复制
 <DataTemplate>
      <Grid>
           <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
           </Grid.ColumnDefinitions>
           <Image Grid.Column="0" ... />
           <StackPanel Grid.Column="1">
                <TextBlock TextWrapping="NoWrap" ... />
                <TextBlock TextWrapping="NoWrap" ... />
                <TextBlock TextWrapping="Wrap" ... />
           </StackPanel>
      </Grid>
 </DataTemplate>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8664762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档