If you??™re on a Button control, pressing Enter triggers it.
ISDEFAULT AND ISDEFAULTED
The Button class also includes the horribly confusing IsDefaulted property, which is read-only. IsDefaulted
returns True for a default button if another control has focus and that control doesn??™t accept the Enter key. In
this situation, pressing the Enter key will trigger the button.
For example, a TextBox does not accept the Enter key, unless you??™ve set TextBox.AcceptsReturn to True.
When a TextBox with an AcceptsReturn value of True has focus, IsDefaulted is False for the default button.
When a TextBox with an AcceptsReturns value of False has focus, the default button has IsDefaulted set to
True. If this isn??™t confusing enough, the IsDefaulted property returns False when the button itself has focus,
even though hitting Enter at this point will trigger the button.
Although it??™s unlikely that you??™ll want to use the IsDefaulted property, it does allow you to write certain
types of style triggers, as you??™ll see in Chapter 12. If not, just add it to your list of obscure WPF trivia, which
you can use to puzzle your colleagues.
The ToggleButton and RepeatButton
Alongside Button, three more classes derive from ButtonBase. These include the following:
??? GridViewColumnHeader, which represents the clickable header of a column when you
use a grid-based ListView.
Pages:
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383