Open SuperJMN opened 7 years ago
The AutoFocusBehavior
follows the control's Control.TabIndex which if not specified, it will default to the order of the controls as they appear in the XAML (in this case TextBox
-> PasswordBox
-> Button
).
You can always specify the TabIndex
on each of the controls to get the order you want!
If all you want is to invoke a command when the Enter key is pressed on the TextBox
control, you can attach a EnterKeyBehavior to it!
Thanks for the lightning fast answer!
I would expect that pressing the Tab Key and the Enter Key would have the same behavior, while it's not true.
In the XAML I posted, if you press Tab, this is the order you'll get
However, pressing Enter will lead you to:
I expected both to be the same
That's a fair point... when I wrote the behavior, I targeted only TextBox
and PasswordBox
, so an update will be required to get the other in!
For now, my advice is for you to copy the behavior code directly to your project and make the appropriate changes (removing the last bit on this line should suffice)
I'll do that. Thank you so much!
Given this XAML, I expect that upon pressing Enter in the PasswordBox, the Focus should be set to the Button. However, the TextBox is focused instead.
IMHO, it would be more useful if the button was focused, since the user can save time this way and will intuitively press Enter again to "Continue"