I have a problem with watermark keydown. I have a keydown event handler like this.
if (e.Key == Key.Tab)
{
FocusManager.GetFocusedElement();
if (FocusManager.GetFocusedElement() == txtPassword)
btnLogin.Focus();
else if (FocusManager.GetFocusedElement() == txtUserName)
txtPassword.Focus();
else
txtUserName.Focus();
}
it works fine, but when the focus is on btnLogin, when you press tab, the focus goes straight to password box. I have inserted breakpoints to no avail. It only passes on the code once, and it enters the else statement. Any ideas? Thanks for all replies.
Not sure what Watermark is, but usually this would be caused by you intercepting the Tab and doing something, then the event bubbling up and being handled again by the default handler.
Try consuming the event, so that this does not happen. Might be something like e.preventDefault(), or e.stopPropagation()