I have a controls on a <UserControl> the first of which is a <telerik:RadComboBox>
I have another control that is a <telerik:RadWatermarkTextBox>
I want the second control to have the focus after the screen loads because the combobox has the OpenDropDownOnFocus property set to true.
I use txtPolicyNumber.Focus(); in the after load event but the Combobox grabs the focus.
I even have this code and it still goes to the combobox:
Any suggestions as to what I can do to make Focus() focus?
I have another control that is a <telerik:RadWatermarkTextBox>
I want the second control to have the focus after the screen loads because the combobox has the OpenDropDownOnFocus property set to true.
I use txtPolicyNumber.Focus(); in the after load event but the Combobox grabs the focus.
I even have this code and it still goes to the combobox:
Any suggestions as to what I can do to make Focus() focus?
FrameworkElement focusedElement = Keyboard.FocusedElement as FrameworkElement; if (focusedElement != null) { string focusedControlName = focusedElement.Name; if (focusedControlName == "txtPolicyNumber") { iefInsuranceThirdPartyVM.CanAutoDrop = true; txtPolicyNumber.Focus(); // WTF is making it focus on the combobox } }
It's caused by OpenDropDownOnFocus=True"
When you come on tot he screen the RadComboBox has focus because it is the first control.
Whatever event is used to drop down the RadComboBox fires before the event to set the focus to the RadWatermarkTextBox.
I can even briefly see it focusing on the RadWatermarkTextBox before the Combobox takes back the focus and drops down the list to select from.
The workaround that I have is to put the RadWatermarkTextBox before the RadComboBox in the xaml.