How to set the focus on an TextBox
element in WPF
I have this code:
txtCompanyID.Focusable = true;
txtCompanyID.Focus();
...but it is not working.
Any idea?
How to set the focus on an TextBox
element in WPF
I have this code:
txtCompanyID.Focusable = true;
txtCompanyID.Focus();
...but it is not working.
Any idea?
You might want to look at this article: http://msdn.microsoft.com/en-us/library/aa969768.aspx
txtCompanyID.Focusable = true;
Keyboard.Focus(txtCompanyID);
msdn:
There can be only one element on the whole desktop that has keyboard focus. In WPF, the element that has keyboard focus will have IsKeyboardFocused set to true.
You could break after the setting line and check the value of IsKeybiardFocused property. Also check if you really reach that line or maybe you set some other element to get focus after that.