TextTrimming="WordEllipsis" truncates entire string

996 Views Asked by At

I have defined a style resource for TexBlock control. Where I am trying to assign it's TextTrimming property as "WordEllipsis". The problem is that the outcome is a blank text instead of some string with some dots.

Here is my style resource:

<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

There are 1 best solutions below

3
On

Try this it is working:

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

as You are giving same height for border and Textblock its not showing the text.