TextTrimming =“WordEllipsis”截断整个字符串

时间:2014-06-05 10:42:37

标签: wpf windows-phone-8 texttrimming

我为TexBlock控件定义了一个样式资源。我试图将它的TextTrimming属性指定为“WordEllipsis”。问题是结果是一个空白文本,而不是带有一些点的字符串。

这是我的风格资源:

<DataTemplate x:Key="ItemTemplate">
    <Grid Margin="12,0,12,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="120" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderBrush="{Binding Status, Converter={StaticResource ContactStatusToColorConvertor}}" BorderThickness="7" CornerRadius="90">
            <Image Source="{Binding ImageUrl, Converter={StaticResource StringToAssetUrlConverter}}" Width="120" Height="120" HorizontalAlignment="Center" Stretch="Fill">
                <Image.Clip>
                    <EllipseGeometry Center="60,53" RadiusX="50" RadiusY="50" />
                </Image.Clip>
            </Image>
        </Border>
        <!--<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Left" Height="30">-->
        <Border Grid.Row="1" BorderThickness="2" Height="30">
            <TextBlock Text="A very loong name" Style="{StaticResource AWTextBlockNormalStyle}" Height="30" TextTrimming="WordEllipsis" TextWrapping="NoWrap"/>
        </Border>
        <!--<TextBlock Text="{Binding LastName}" Margin="3,0,0,0" Style="{StaticResource AWTextBlockNormalStyle}" TextTrimming="WordEllipsis" />-->
        <!--</StackPanel>-->
    </Grid>
</DataTemplate> ##

1 个答案:

答案 0 :(得分:1)

尝试这样做是有效的:

    <Border Grid.Row="1" BorderThickness="2" Height="50">
        <TextBlock Text="A very loong name" Height="30" TextTrimming="WordEllipsis" TextWrapping="NoWrap" Width="100"/>
    </Border>

因为您为heightborder提供了相同的Textblock,但它没有显示文字。