Friday, August 8, 2014

WPF: Label vs. Textblock

I wanted to concatenate all the differences into a table form:

Label Textblock
System.Windows.Controls namespace, and is a control System.Windows.Controls namespace, but is not a control
derives from ContentControl derives directly from FrameworkElement
Input can be anything (strings, integers, dates, shapes/images, etc.) Input is only string
support multi-line text output via TextWrapping property support single line text output only
Option for: Custom control template (Template property) and DataTemplate to content (ContentTemplate property). Also, label text can have access keys (focus handling) and appears grayed out when not in use. Lighter and quicker way to display text (because only Strings).