Wednesday, March 9, 2011

Label (Code)

Traditionally the Label control has been the standard way to display short text strings in forms and dialog boxes. For example, here's a label that might appear in a File Open dialog:

Label lbl = new Label();
lbl.Content = "File _name:"; 
 
With versatile elements such as TextBlock, the Label control would seem to be obsolete, but it's really not, and the key to its longevity is the ability to use underscores in text that you assign to the Content property. In a File Open dialog box, pressing Alt+N shifts the input focus not to the labelbecause labels are commonly non-focusablebut to the control after the label, which is probably a TextBox control that lets the user enter and edit text. Thus, labels continue to maintain their role as assistants in keyboard navigation.


No comments:

Post a Comment