Prev | Current Page 370 | Next

Matthew MacDonald

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

Its behavior depends on your current location in the window. If
you??™re positioned on a non-Button control (such as a TextBox, RadioButton, CheckBox,
and so on), the default button is given a blue shading, almost as though it has focus. If
you press Enter, this button is triggered. However, if you??™re positioned on another Button
control, the current button gets the blue shading, and pressing Enter triggers that
button, not the default button.
Many users rely on these shortcuts (particularly the Escape key to close an unwanted dialog
box), so it makes sense to take the time to define these details in every window you create.
It??™s still up to you to write the event handling code for the cancel and default buttons, because
WPF won??™t supply this behavior.
In some cases, it may make sense for the same button to be the cancel button and the
default button for a window. One example is the OK button in an About box. However, there
should be only a single cancel button and a single default button in a window. If you designate
more than one cancel button, pressing Escape will simply move the focus to the next default
button but it won??™t trigger it. If you have more than one default button, pressing Enter has a
somewhat more confusing behavior. If you??™re on a non-Button control, pressing Enter moves
you to the next default button.


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