NoWrap Ignored In Label

Nathan Sokalski 4,126 Reputation points
2020-12-23T03:23:33.73+00:00

I have a CollectionView in which the ItemTemplate contains a Grid, which has 2 ColumnDefinition(s): Auto & *. The second column contains a Label with LineBreakMode="NoWrap". When the text is too long to fit, I want it to be clipped (not wrapped), even if this means some of the text becomes not visible. However, the text seems like it is wrapping. Here is a screenshot:
50627-screenshot-2020-12-22-221451.png
The XAML for the Label is as follows:

<Label Grid.Column="1" HorizontalOptions="FillAndExpand" VerticalOptions="Fill" LineBreakMode="NoWrap" FontSize="36" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" TextColor="Black" BackgroundColor="{Binding PlayerIndex,Converter={StaticResource Places},ConverterParameter=Color}" FontFamily="Arial" Margin="0" Padding="5,0,0,0" Text="{Binding NameTotal}"/>  

How can I cause the text to be clipped rather than wrapped? Isn't that what LineBreakMode="NoWrap" is supposed to do? Is this something I need to do in a Custom Renderer (in case it is of any significance here, I am using Android)? Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2020-12-23T07:49:18.343+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    How can I cause the text to be clipped rather than wrapped?

    If you want the long text to be clipped , you can try the following value( HeadTruncation, MiddleTruncation , TailTruncation) for property LineBreakMode

    50744-image.png

    Best Regards,

    Jessie Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.