Is there a way to tell if a label will truncate text?

I have an iOS implementation I am trying to port to forms.
In the iOS version I show full names but if the name will be longer than the field width I use first initial and last name, if it still doesnt fit then it gets truncated with ellipses. Basically in my iOS version I measure the text using nsstring.GetSizeUsingAttributes.

Is there a way I can do this in Forms?

Maybe I can make a custom binding converter or something, just not sure if there is a similar way to measure text.

Thanks,
Jason

Tagged:

Best Answer

Answers

  • JasonMichasJasonMichas USMember ✭✭

    @AdamP - Yeah, as usual, almost immediately after I posted my question I thought of implementing a dependency service of the implementation I already had for the native iOS version. So, I will have to do one per platform, but thats OK.

    Thanks for the answer!

  • KymPhillpotts.3866KymPhillpotts.3866 AUXamarin Team, University, XamUProfessors Xamurai

    Depending on how specific you need to be with your text measurements you might want to have a look at Charles Petzolds chapter on sizing. (Chapter 5 - https://developer.xamarin.com/guides/cross-platform/xamarin-forms/creating-mobile-apps-xamarin-forms/).

    He does some pretty great stuff with approximating text sizes in that chapter.

  • JasonMichasJasonMichas USMember ✭✭

    @Kym_Phillpotts Cool, thanks I will check that out.

Sign In or Register to comment.