Represents an explicit new line in a TextBlock.
| XAML | <LineBreak .../> |
| Scripting | To create an object using scripting, see CreateFromXAML. |
Properties
FontFamily,
FontSize,
FontStretch,
FontStyle,
FontWeight,
Foreground,
Name,
TextDecorations
Methods
Equals,
FindName,
GetHost,
GetValue,
SetValue
Examples
The following XAML example shows how to use LineBreak objects to force the formatted text strings defined in the Run objects to display on separate lines.
| XAML |
<!-- Display formatted text as Run objects within a TextBlock. -->
<Canvas
xmlns="http://schemas.microsoft.com/client/2007">
<TextBlock
FontFamily="Arial" Width="400" Text="Sample text formatting runs">
<LineBreak/>
<Run Foreground="Maroon" FontFamily="Courier New" FontSize="24">Courier New 24</Run>
<LineBreak/>
<Run Foreground="Teal" FontFamily="Times New Roman" FontSize="18" FontStyle="Italic">Times New Roman Italic 18</Run>
<LineBreak/>
<Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="14" FontWeight="Bold">Verdana Bold 14</Run>
</TextBlock>
</Canvas>
|
The following illustration shows the rendered formatted text from the previous XAML content example.
Rendered formatted text
Without the LineBreak object, the text in each Run would flow together as one line, and eventually be truncated after exceeding the TextBlock's Width value. The following illustration shows how the formatted text would
render without using LineBreak objects.
Rendered formatted text without line breaks
See Also
Text and Fonts Overview
TextBlock
Run