Export (0) Print
Expand All
Expand Minimize

TextTrimming Enumeration

Describes how text is trimmed when it overflows the edge of its containing box.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
public enum TextTrimming
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
public enum TextTrimming
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
public enum TextTrimming
<object property="EnumerationValue" .../>

 Member nameDescription
CharacterEllipsisText is trimmed at a character boundary. An ellipsis (...) is drawn in place of remaining text. 
NoneText is not trimmed. 
WordEllipsisText is trimmed at a word boundary. An ellipsis (...) is drawn in place of remaining text. 

This example demonstrates the usage and effects of the values available in the TextTrimming enumeration.

The following example defines a TextBlock element with the TextTrimming attribute set.

<TextBlock 
  Name="myTextBlock" 
  Margin="20" Background="LightGoldenrodYellow" 
  TextTrimming="WordEllipsis" TextWrapping="NoWrap"
  FontSize="14"
>
  One<LineBreak/>
  two two<LineBreak/>
  Three Three Three<LineBreak/>
  four four four four<LineBreak/>
  Five Five Five Five Five<LineBreak/>
  six six six six six six<LineBreak/>
  Seven Seven Seven Seven Seven Seven Seven
</TextBlock>

Setting the corresponding TextTrimming property in code is demonstrated below.

myTextBlock.TextTrimming = TextTrimming.CharacterEllipsis;

There are currently three options for trimming text: CharacterEllipsis, WordEllipsis, and None.

When TextTrimming is set to CharacterEllipsis, text is trimmed and continued with an ellipsis at the character closest to the trimming edge. This setting tends to trim text to fit more closely to the trimming boundary, but may result in words being partially trimmed. The following figure shows the effect of this setting on a TextBlock similar to the one defined above.

Example: TextTrimming.CharacterEllipsis

When TextTrimming is set to WordEllipsis, text is trimmed and continued with an ellipsis at the end of the first full word closest to the trimming edge. This setting will not show partially trimmed words, but tends not to trim text as closely to the trimming edge as the CharacterEllipsis setting. The following figure shows the effect of this setting on the TextBlock defined above.

Example: TextTrimming.WordEllipsis

When TextTrimming is set to None, no text trimming is performed. In this case, text is simply cropped to the boundary of the parent text container. The following figure shows the effect of this setting on a TextBlock similar to the one defined above.

Example: TextTrimming.None

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft