在网格中的文本块中包装文本

时间:2012-05-31 02:07:40

标签: wpf textblock textwrapping

我有一个格子如下
  

      <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="115"/>
            <ColumnDefinition Width="140"/>
            <ColumnDefinition Width="115"/>
            <ColumnDefinition Width="140"/>
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="0" Grid.Row="0" Margin="5" Grid.RowSpan="5">
            <Border Margin="-1,-1,-1,-1" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2">
                <Border BorderThickness="1,1,1,1" CornerRadius="1,1,1,1" Background="#FFFFFFFF">
                    <Border.BorderBrush>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF2F2F2F" Offset="1" />
                            <GradientStop Color="#FF515151" Offset="0.008" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                    <Image Margin="5" Stretch="Fill" HorizontalAlignment="Left"
                           VerticalAlignment="Top"  Width="150" Height="150"
                           Tag="{Binding ID}" >
                    </Image>
                </Border>
            </Border>
        </StackPanel>

        <TextBlock Text="Lorem: " Grid.Row="1" Grid.Column="1"  FontWeight="Bold" />
        <TextBlock x:Name="txtId" Text="{Binding lorem}" Grid.Row="1" Grid.Column="2"/>
        <TextBlock Text="Status: " Grid.Row="1" Grid.Column="3" FontWeight="Bold"/>
        <TextBlock Text="{Binding Status}" Grid.Row="1" Grid.Column="4"/>

        <TextBlock Text="DTime: " Grid.Row="2" Grid.Column="1" FontWeight="Bold"/>
        <TextBlock x:Name="txtDetectTime" Text="{Binding DTime}" Grid.Row="2" Grid.Column="2"/>
        <TextBlock Text="CTime: " Grid.Row="2" Grid.Column="3" FontWeight="Bold"/>
        <TextBlock Text="{Binding CTime}" Grid.Row="2" Grid.Column="4" />
        <TextBlock Text="ClTime: " Grid.Row="3" Grid.Column="1"  FontWeight="Bold"/>
        <TextBlock Text="{Binding ClTime}" Grid.Row="3" Grid.Column="2"/>
        <TextBlock Text="Coordinate: " Grid.Row="4" Grid.Column="1" FontWeight="Bold"/>
        <TextBlock Text="{Binding Coordinate}"  Height="Auto" Grid.Row="4" Grid.Column="2" TextWrapping="WrapWithOverflow" Grid.RowSpan="2" />
        <TextBlock Text="Remark: " Grid.Row="4" Grid.Column="3" FontWeight="Bold"/>
        <TextBlock Text="{Binding Remark}" Grid.Row="4" Grid.Column="4"  Height="Auto" TextWrapping="WrapWithOverflow" Grid.RowSpan="2"/>


    </Grid>

现在最后一行中的Text通常很长,我想要包装文本。但是文本根本没有包装。

0 个答案:

没有答案