textblock (plural textblocks) The block of pages making up a book, excluding the binding.
Text inside a TextBlock can not be made selectable by the user. TextBoxes are used for displaying text more focused for content input or when content is needed to be made selectable by the user. The TextBox can only be set to one colour, one font size, one font type etc.
The TextBlock control provides flexible text support for 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.
Advertisements. The Label class provides both functional and visual support for access keys (also known as mnemonics). It is frequently used to enable quick keyboard access to controls.
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:
Template
property).Content
property).DataTemplate
to its content (via the ContentTemplate
property).Do whatever else a ContentControl
can do that a FrameworkElement
cannot.
Label
text is grayed out when disabledLabel
supports access keysLabel
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
.
Although TextBlock and Label are both used to display text, they are quite different under the covers.
=> Label inherits from ContentControl, a base class that enables the display of almost any UI imaginable.
=> TextBlock, on the other hand, inherits directly from FrameworkElement, thus missing out on the behavior that is common to all elements inheriting from Control. The shallow inheritance hierarchy of TextBlock makes the control lighter weight than Label and better suited for simpler, noninteractive scenarios.
PS: However, if you want access keys to work or want a more flexible or graphical design, you’ll need to use Label.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With