I have a specific behavior I want to achieve with respect to the AutoCompleteBox.
- When the box is empty the pop-up must suggest all options, much like a combo-box does
- When the box gets focus, the pop-up must open and show the corresponding suggestions
- Selection must be achieved through hitting enter key or clicking an item on the pop-up
- Implement a FilteringBehavior to return all items when search text is empty
- Upon receiving a GotFocus event perform a Populate on the auto-complete box
- Setting up the RadAutoCompleteBox on Xaml
- Requirements 1 and 2 are achieved successfully
- With a highlighted item in the popup, hitting enter commits the selection into the box and closes the popup
- While cycling focus through a series of text boxes and auto complete boxes the first option gets selected when the tab key is hit
- Users cannot select any item while mouse-left-clicking on items in the pop-up
Is there any way to avoid the unwanted behavior while on this setup?
9 Answers, 1 is accepted
I will go straight yo your issues. The observed by you behavior of RadAutoCompleteBox is caused when the control does not get populated as expected inside the GotFocus event. So, what you need to do is when the Populate method gets called inside the GotFocus event you need first to check if the DropDown is not opened, as shown below:
About your second issues concerning the Tab selection. What we could suggest in order to prevent the item to be selected when tab gets pressed and the DropDown is open is to handle the PreviewKeyDown event of the control and implement the following logic:
So, basically when the tab key is pressed and the DropDown is opened the focus will be moved to the next UIElement.
Hope this helps.
I'll try this solution promptly and give you feedback.
Take as much as time as you need to check the proposed approaches.
Meanwhile, if you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.
It worked perfect
Following your instructions I finally did the following
I just added conditions for Tab and Shift+Tab key combinations.
I am glad to hear the proposed approach worked for you and thank you for sharing with the community your final implementation.
If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.
I tried same code, but User cannot seelct any items while left clicking on items in the pop-up with mouse.
Can you please check , why item is not selected when user selects mouse left click.
its working for me by placing "!radAutoCompleteBox.IsDropDownOpen" condition...
For RadAutoCompleteBox, the selection of items is not working for mouse left click.
Can you give me some guidance on how to achieve this functionality
Could you please, provide some more information about your scenario? Are you populating the AutoCompleteBox with items when you focus it. If that is the case please, check if t you have the condition for the IsDropDownOpen property:
However, if that is not the case with your scenario, please isolate the issue in a sample project and send it to us - thus we could be able to investigate it further and provide you with a prompt solution.
Hope this helps.
Telerik by Progress