Search code examples
xamarin.formsright-to-left

Truncate label text from the left


I have a Label that displays the full name and path of the file that the app is currently processing.

The way Labels perform text truncation, the "C:\..." part of the path is always shown, while the actual file name is only shown if it fits. I would rather truncate on the left side, so that the file name is always shown, while the "C:\..." part is only shown if it fits.

Is this possible in Xamarin Forms?


Solution

  • If you read the docs these are the options for truncation

    • HeadTruncation – truncates the head of the text, showing the end.
    • CharacterWrap – wraps text onto a new line at a character boundary.
    • MiddleTruncation – displays the beginning and end of the text, with the middle replace by an ellipsis.
    • NoWrap – does not wrap text, displaying only as much text as can fit on one line.
    • TailTruncation – shows the beginning of the text, truncating the end. WordWrap – wraps text at the word boundary.

    HeadTruncation appears to be what you're looking for