【问题标题】:Use of WrapPanelWrapPanel 的使用
【发布时间】:2011-12-29 18:31:49
【问题描述】:

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

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

例如在垂直视图中,列表框的宽度很小,所以文本应该是:

           match is between India and
           pakistan

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

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

提前致谢!

>

【问题讨论】:

    标签: windows-phone-7 c#-4.0 silverlight-4.0


    【解决方案1】:
     <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>
    

    【讨论】:

      猜你喜欢
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多