Prev | Current Page 368 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

(If you really do want an
underscore to appear in your label, you must add two underscores instead.) All mnemonics
work with Alt and the shortcut key you??™ve identified. For example, if the user presses Alt+A in
this example, the first label transfers focus to the linked control, which is txtA. Similarly, Alt+B
takes the user to txtB.
nNote If you??™ve programmed with Windows Forms, you??™re probably used to using the ampersand (&) character
to identify a shortcut key. XAML uses the underscore instead because the ampersand character can??™t
be entered directly in XML??”instead, you need to use the clunkier character entity & in its place.
CHAPTER 7 n CLASSIC CONTROLS 194
Usually, the shortcut letters are hidden until the user presses Alt, at which point they
appear as underlined letters (Figure 7-2). However, this behavior depends on system settings.
nTip If all you need to do is display content without support for mnemonics, you may prefer to use the
more lightweight TextBlock element. Unlike the Label, the TextBlock also supports wrapping through its
TextWrapping property.
Figure 7-2. Shortcuts in a label
Buttons
WPF recognizes three types of button controls: the familiar Button, the CheckBox, and the
RadioButton. All of these controls are content controls that derive from ButtonBase.


Pages:
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380