If I display a string too long for a TextBlock it just appears to keep writing past the edge of the TextBlock. I'd rather it use the common technique of adding an ellipsis ("...") if the text is not going to fit in the space provided. How should I go about doing this in Silverlight?
The references I've found all use the TextRenderer class which is not available in Silverlight
You didn't say which Silverlight version this is. Assuming Silverlight 4, it's baked into TextBlock via the TextTrimming property.
<TextBlock TextTrimming="WordEllipsis"/>
The only thing you have to do is make sure your TextBlock's width is properly restricted and you use NoWrap for TextWrapping.
Set the TextTrimming property to WordEllipsis.
<TextBlock Text="My long text" TextTrimming="WordEllipsis"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With