0

我为 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> ##
4

1 回答 1

1

试试这个它正在工作:

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

因为你给了同样height的东西borderTextblock但它没有显示文字。

于 2014-06-05T11:01:00.790 回答