One of my recent requirements has been to truncate text based on a number of lines. This is a key design feature for an app that I am currently building for the Guardian. It is easy to write an extension method to shorten text based on a number of characters or words, but not on number of generated lines – especially when dealing with orientation changes.
I was really pleased to discover that in the Mango release of Windows Phone, “Textblock” now includes a TextTrimming property, which is used as follows:
<TextBlock Height=”108″ TextTrimming=”WordEllipsis” />
(if you don’t know, an ellipsis is three dots ‘…’)
Brilliant!