#842 – The Differences Between Label and TextBlock
June 14, 2013 1 Comment
You can use either Label or TextBlock elements to display text in an application.
<Label Content="I'm a Label"/> <TextBlock Text="I'm a TextBlock"/>
The two elements appear to behave similarly, but there are a few differences:
- A Label
- Can have an access key (mnemonic), allowing the user to give focus to a related control
- Has a built-in border (BorderBrush, BorderThickness)
- Has a Content property that can be set to some other element
- Can use templates to customize the entire control or the content area of the control
- Can align its content with HorizontalContentAlignment and VerticalContentAlignment
- Will render as grey when IsEnabled is false
- A TextBlock
- Can have richer text formatting, using inline formatting
- Can wrap its text to multiple lines
- Can hyphenate words
- Allows specifying space between lines
- Allows left/right/center justification using the TextAlignment property
- Supports text decorations (e.g. underline, baseline)
- Allows setting typography properties
Pingback: Dew Drop – June 14, 2013 (#1,568) | Alvin Ashcraft's Morning Dew