views:

81

answers:

1

Lets say you have this text

"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna."

put in a textblock with TextWrapping="Wrap", the textblock only supports 2 lines, so how do I add the usual "..." at the end of the text so as to say there is more to read

+2  A: 

This is not trivial to answer for use in SilverLight because you cannot use native Win32 methods (of which some methods support ellipsis). There are a few resources on the Net, which basically come down to one of two approaches:

  1. Do-it-yourself calculation, here's a ready made class, you may need to alter it a bit to work with more then one line: http://www.codeproject.com/KB/cs/AutoEllipsis.aspx
  2. Use TextRenderer.DrawText, not sure if that's available or useful in your scenario: http://www.switchonthecode.com/tutorials/how-to-auto-ellipse-text-in-csharp
Abel