telerik:RadComboBox grabs the focus

0 Answers 45 Views
ComboBox
Paul
Top achievements
Rank 2
Iron
Iron
Iron
Paul asked on 27 Feb 2024, 04:48 PM
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?
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
    }
}


Martin Ivanov
Telerik team
commented on 28 Feb 2024, 12:46 PM

There is no code in the RadComboBox that automatically steals the focus. I also double checked this, but couldn't reproduce the issue. The RadWatermarkTextBox is taking the focus properly. You can see this in the attached project.
Paul
Top achievements
Rank 2
Iron
Iron
Iron
commented on 04 Mar 2024, 12:11 PM

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.

Martin Ivanov
Telerik team
commented on 05 Mar 2024, 08:18 AM

There is not automatic mechanism to focus the first element in the view, so this should be achieved with application logic that resides in your application (or in method from a third party library). This means that you should be able to find and modify or replace the code that focuses the first element in the view, in order to change the focus if the first element is RadComboBox.

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Paul
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or