EditCategory
Controls
EditQuestion
What is the difference between the TextBlock and the Label controls?
EditAnswer
TextBlock is a class specialized for the display of simple text. In contrast, the Label class participates in what is called the Content Model. The Content Model states that an object should expose a Content property, which can be used to display any kind of content, such as text, images, controls, etc. If you are sure that you simply need to display some simple text, the TextBlock is best suited for your needs. However, if you are not sure, Label should be used. Label also has a "Target" property which is helpful for accessibility.
Label also uses the underscore ("_") character to indicate keyboard accelerators. If a Label's Content is set to the string "_Name", then the Label strips out the "_" and just displays "Name"; but if you press the Alt key, the "N" will be shown underlined, and pressing Alt+N will cause the label's Target control to receive focus. TextBlock doesn't do anything special with underscores, and displays them normally.