How to detect if a label text is truncated, in Xamarin Forms?

408 Views Asked by At

The label text is coming dynamically, sometimes it is short and sometimes it is huge. I am using LineBreakMode = TailTruncation and I want to detect that if the text is truncated, I need to show the icon for see more, otherwise not. So, is there a way in Xamarin Forms to detect/check, if the label text is truncated or not?

1

There are 1 best solutions below

0
On

There is no such event can detect if text is truncated, normally the max characters in label equal the width of label divided by 10 if you not set the fontsize of text. So, you can use code below to know if the text is truncated as a workaround:

if(mylabel.Text>((mylabel.width/10)))
{sth to be added
}