Label和TextBlock之间的区别 [英] Difference between Label and TextBlock
本文介绍了Label和TextBlock之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据使用Microsoft进行Windows应用程序开发. NET 4 70-511 培训套件
Label
控件和TextBlock
控件之间有什么区别,因为它们都是内容控件并且仅显示文本?
What is the difference between the Label
control and TextBlock
control since both are content controls and just displaying text?
推荐答案
TextBlock不是控件
即使TextBlock
位于System.Windows.Controls命名空间中,它也不是控件.它直接从FrameworkElement
派生.另一方面,标签是从ContentControl
派生的.这意味着Label
可以:
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:
- 被赋予自定义控件模板(通过
Template
属性). - 显示不仅仅是字符串的数据(通过
Content
属性). - 将
DataTemplate
应用于其内容(通过ContentTemplate
属性). -
执行
ContentControl
可以执行的其他任何操作,FrameworkElement
不能执行的操作.
- 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
禁用时文本显示为灰色 -
Label
支持访问键 -
Label
比TextBlock
重得多
Label
text is grayed out when disabledLabel
supports access keysLabel
is much heavier thanTextBlock
下面一些更有趣的读物
- http://www.wpfwiki.com/WPF%20Q4.1.ashx
- What is the difference between the WPF TextBlock element and Label control?
这篇关于Label和TextBlock之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文