Text Block
The text block is a read-only label for the display of text. It can display multiple lines, and features full control over the font used.
Useful Properties
You will probably use these properties most often:
Property | Description |
---|---|
FontSize | The size of the font. |
FontWeight | The weight of the font. Default is normal, options include Bold'. |
FontStyle | A style to apply to the lettering. Default is normal, options include Italic. |
TextDecorations | A line decoration to apply to the lettering. Default is none, options include Underline, Strikethrough, Baseline and Overline. To apply more than one at the same time, list the options with spaces between. |
Example
This example shows a text block used as a heading, single line and multi-line displays.
<StackPanel Margin="20">
<TextBlock Margin="0 5" FontSize="18" FontWeight="Bold">Heading</TextBlock>
<TextBlock Margin="0 5" FontStyle="Italic">This is a single line.</TextBlock>
<TextBlock Margin="0 5">This is a multi-line display
that has returns in it.
The text block repects the line breaks
as set out in XAML.</TextBlock>
</StackPanel>
The styling works in the preview pane:
 (5).png)
More Information
info
For the complete API documentation about this control, see here.
info
View the source code on GitHub TextBlock.cs