Share via


TextBlock Overview

The TextBlock control provides flexible text support for WPF applications. The element is targeted primarily toward basic UI scenarios that do not require more than one paragraph of text. It supports a number of properties that enable precise control of presentation, such as FontFamily, FontSize, FontWeight, TextEffects, and TextWrapping. Text content can be added using the Text property. When used in XAML, content between the open and closing tag is implicitly added as the text of the element.

For an explanation of all properties declared on TextBlock, see TextBlock Properties Sample.

A TextBlock element can be instantiated very simply using XAML.

<TextBlock FontSize="18" FontWeight="Bold" FontStyle="Italic">
  Hello, world!
</TextBlock>

Similarly, usage of the TextBlock element in code is relatively simple.

Dim myTextBlock As New TextBlock()
myTextBlock.FontSize = 18
myTextBlock.FontWeight = FontWeights.Bold
myTextBlock.FontStyle = FontStyles.Italic
myTextBlock.Text = "Hello, world!"
TextBlock myTextBlock = new TextBlock();
myTextBlock.FontSize = 18;
myTextBlock.FontWeight = FontWeights.Bold;
myTextBlock.FontStyle = FontStyles.Italic;
myTextBlock.Text = "Hello, world!";

See Also

Tasks

TextBlock Properties Sample

Reference

Label

Change History

Date

History

Reason

January 2010

Removed incorrect information.

Content bug fix.