According to the Windows Applications Development with Microsoft .NET 4 70-511 Training Kit
What is the difference between the Label
control and TextBlock
control since both are content controls and just displaying text?
ベストアンサー1
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:
- Be given a custom control template (via the
Template
property). - Display data other than just a string (via the
Content
property). - Apply a
DataTemplate
to its content (via theContentTemplate
property). Do whatever else a
ContentControl
can do that aFrameworkElement
cannot.Label
text is grayed out when disabledLabel
supports access keysLabel
is much heavier thanTextBlock
Some more interesting reads below