Wpf TextBlock TextWrapping未包装#2

Wpf TextBlock TextWrapping未包装#2,wpf,xaml,textblock,word-wrap,Wpf,Xaml,Textblock,Word Wrap,好的。。。所以解决方案没有帮助 XAML在这里 <ListBox ItemsSource="{Binding Path=ContentItems}" Background="White" > <ListBox.ItemTemplate> <DataTemplate> <Grid Margin="2" Height="Auto" W

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

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>

开始
终点

您的
文本块
不需要包装,因为您将
宽度
指定为
自动
,因为它的
列定义
允许它获取容纳内容所需的所有
宽度
,即使以溢出为代价。您需要将列的宽度设置为“*”以允许
TextWrapping
在请求的宽度超过允许宽度时启动,或者使用类似于

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

以下内容有助于文本包装:
The following will helps for text wrapping:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">