Subscribe to our YouTube Channel for more Videos

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

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.