6

In my app in Xamarin.Forms I have a label that I want to be multiline but only to a certain point. After that it must be truncated. How can I achieve this?

Currently I can set the LineBreakMode to WordWrap; this creates a multiline label, but there is no truncating.

If it changed the LineBreakMode to TailTruncation, it always truncates after one line.

David Pilkington
  • 13,528
  • 3
  • 41
  • 73
  • Why not manually truncate and add ellipses? You can use this method in order to do that http://stackoverflow.com/a/6724896/1341538 – Andres Castro Oct 29 '15 at 20:45

2 Answers2

1

You can write a value converter that get the text and return truncated text in the certain point. In the converter, you should remove string from the certain point and yourself put three ... at the end of text.

zohre moradi
  • 119
  • 4
0

You'll have to use an effect or renderer to achieve this. For example, on iOS, you could make an effect for a Label that sets the native UILabel to have Lines = 0 and LineBreakMode = UILineBreakMode.TailTruncation.

therealjohn
  • 2,378
  • 3
  • 23
  • 39