In Silverlight 4, a property called TextTrimming is
added to TextBlock, which will help the TextBlock to Trim a string up to a
defined width. In this article we will see how this feature
works.Creating Silverlight Project
Fire up Visual Studio
2010 and create a new Silverlight Application Project. Name it as
will look at some TextBlocks to see how TextTrimming works in Silverlight
above TextBlock is a normal TextBlock whose Width is set to Auto by
In design view it would look like following.
examine another TextBlock whose Width is set to 290.
design view, the above TextBlock looks like the following.
we have a TextBlock whose Width is set to 150 and whose TextTrimming property is
set to "WordEllipsis".
design view it would render text as shown below.
run the application and resize the Browser Window.
You will see The
TextBlock which has the TextTrimming property set to "WordEllipsis"
will trim the width of the fully rendered string to fit into the width described
by the Width
property of the TextBlock control.
TextTrimming the width of a TextBlock whose content exceeds the width of the
control, the TextBlocks view looks like the top line of the diagram below. When
we set the TextTrimming property of a TextBlock whose content exceeds the width
of the control, the TextBlock View produces the ellipse shown in the last line
of the diagram.
this article helps you understand how to take advantage of text trimming in your
You can also download the sample project used in above example.