【问题标题】:TextBlock TextWrapping not wrapping #2TextBlock TextWrapping 不换行 #2
【发布时间】:2013-04-25 17:28:42
【问题描述】:

好的...所以this 解决方案没有帮助

XAML 在这里

  <ListBox  ItemsSource="{Binding Path=ContentItems}" Background="White" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2" Height="Auto" Width="Auto">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <StackPanel Grid.Row="0" Orientation="Horizontal">
                                    <Label VerticalAlignment="Center"  Margin="0,0,0,5">Start</Label><svl:TimeEditor Value="{Binding Path=FormatedStart}" Width="87"  HorizontalAlignment="Left"  Margin="2,8"  Name="dtpStart" FontSize="12"  Height="25"  VerticalAlignment="Center"     />
                                    <Label VerticalAlignment="Center"  Margin="0,0,0,5">End</Label><svl:TimeEditor Value="{Binding Path=FormatedEnd}" Width="87"  HorizontalAlignment="Left"  Margin="2,8"  Name="dtpEnd" FontSize="12"  Height="25"  VerticalAlignment="Center"     />
                                </StackPanel>                               
                                <TextBlock Grid.Row="1"  TextWrapping="Wrap"  Name="tbText" Text="{Binding Path=Data}"></TextBlock>
                            </Grid>
                            <Grid Grid.Column="1" Visibility="Collapsed">
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

【问题讨论】:

    标签: wpf xaml textblock word-wrap


    【解决方案1】:
    The following will helps for text wrapping:
    
    <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">
    

    【讨论】:

      【解决方案2】:

      您的TextBlock 不需要换行,因为您将Width 指定为Auto,因为它是ColumnDefinition,它允许它获取它需要的所有Width,即使以溢出为代价。您需要将列的宽度设置为“*”以允许TextWrapping 在请求的宽度超过允许时启动,或者使用类似的绑定手动强制MaxWidth 在其上

      <TextBlock Name="tbText" Grid.Row="1" MaxWidth="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth}" Text="{Binding Path=Data}" TextWrapping="Wrap" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-27
        相关资源
        最近更新 更多