Windows Phone 8.1 and Windows Runtime Apps How to #14 – Text Trimming for TextBlock Element.

The Text Trimming described how a text can be trimmed when it exceeds the width of the current text block .

In Windows Phone 8.1 , the TextBlock has the property TextTrimming that allows the developers to trim the text in 4 different ways.

This property takes one of the TextTrimming enum values

  • None
  • WordEllipsis
  • CharacterEllipsis
  • Clip

For example , the TextTrimming property can be set like the way shown in the below XAML code snippet.

<TextBlock TextTrimming="WordEllipsis"  Width="75px" MaxHeight=”400px” >Welcome to developerpublish.com</TextBlock>

When the TextTrimming is set to “None” , the Text is not trimmed .

image

When the TextTrimming is set to “WordEllipsis” , the text is trimmed at a word boundary and an ellipsis is written in the end.

image

When the TextTrimming is set to CharacterEllipsis , the text is trimmed at a character boundary and an ellipsis is written in the end. This feature was introduced from Windows Phone 8.1(Windows Runtime App) or Windows 8.1.

image

When the TextTrimming is set to “Clip” , the text is trimmed without drawing an ellipsis . image

Leave a Reply