Timo Korinth

2 Meter, 2 Mark

Text Trimming in Silverlight and WPF


Somewhat hidden in the variety of properties of the TextBlock control, is a function for text trimming in WPF and Silverlight. Without much cost it is possible to automatically trim long texts in a TextBlock control and show three periods instead. Here’s an example of this behavior:

Text got enough space and isn’t trimmmed.


Control is to small for the text and get trimmed (WordEllipsis).


Only in WPF: (CharacterEllipsis)

This behavior can be controlled by the “TextTrimming” Property of the TextBlock control. In WPF there is an extra Value for this property: “CharacterEllipsis”. This has the effect, that the text trimming occurs in the middle of a word, if the space is too small. WATCH OUT: In Order to get the right result, set the “TextWrapping” property of the TextBlock to “NoWrap”.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.