TextWrapping Property

Gets or sets a value that indicates how the TextBlock should wrap text.

XAML
<object TextWrapping="TextWrapping" .../>
Scripting
value = object.TextWrapping
object.TextWrapping = value

Property Value

TextWrapping

A value of the enumeration that indicates how the TextBlock should wrap text.

This property is read/write. The default value is NoWrap.

Remarks

The TextWrapping property indicates how text should wrap in a TextBlock. The TextWrapping enumeration defines two values: NoWrap, and Wrap.

ActualHeight and ActualWidth are read-only properties that report the rendered height and width of the TextBlock; these properties can be different than the Height and Width properties of the TextBlock. Setting the TextWrapping property affects the ActualHeight and ActualWidth values of the TextBlock. The following illustation shows how the TextWrapping property affects ActualHeight and ActualWidth.

How TextWrapping affects ActualWidth and ActualHeight

How TextWrapping affects ActualWidth and ActualHeight

Examples

The following XAML example shows how to set the TextWrapping property to NoWrap and Wrap:

XAML
<!-- TextBlock with no text wrapping -->
<TextBlock
  Text="The quick red fox jumped over the lazy brown dog."
  Width="200"
  TextWrapping="NoWrap" />

<!-- TextBlock with text wrapping -->
<TextBlock
  Canvas.Top="40"
  Text="The quick red fox jumped over the lazy brown dog."
  Width="200"
  TextWrapping="Wrap" />

The following illustration shows the rendered text from the previous XAML example.

TextBlock rendering non-wrapped and wrapped text

TextBlock rendering non-wrapped and wrapped text

Applies To

TextBlock

See Also

Text and Fonts Overview
ActualHeight
ActualWidth

Community Additions

Show: