Difference between Label and TextBlock Difference between Label and TextBlock wpf wpf

Difference between Label and TextBlock


TextBlock is not a control

Even though TextBlock lives in the System.Windows.Controls namespace, it is not a control. It derives directly from FrameworkElement. Label, on the other hand, derives from ContentControl. This means that Label can:

  1. Be given a custom control template (via the Template property).
  2. Display data other than just a string (via the Content property).
  3. Apply a DataTemplate to its content (via the ContentTemplate property).
  4. Do whatever else a ContentControl can do that a FrameworkElement cannot.

    • Label text is grayed out when disabled
    • Label supports access keys
    • Label is much heavier than TextBlock

Source

Some more interesting reads below


Labels usually support single line text output while the TextBlock is intended for multiline text display.

For example in wpf TextBlock has a property TextWrapping which enables multiline input; Label does not have this.


Label is ContentControl which means that you can set anything as a content for it. Absolutely anything including strings, numbers, dates, other controls, images, shapes, etc. TextBlock can handle only strings.