I want to disable all highlight in the RadAutoCompleteBox dropdown list. So I have HighlightBehavior.FindHighlightedIndex which returns -1. But, still one item in ItemsSource is highlighted. How can I fix it?
FYI: On entering EACH new character in the search text box, we are calling a web service which returns a list of recommended search strings from history. (This behavior is similar to google search box.) And we set that list to ItemsSource property. This service call takes a few milliseconds.
Observation: after hitting a new character in search box, FindHighlightedIndex is called, which returns -1, and after that, our service returns a new set of strings to be set in dropdown list, and that list is set to the ItemsSource property.
Kindly suggest how to fix this.
Thanks.
Our code snippet below:
public class NoSuggestionItemHighlightBehavior : HighlightBehavior
{
public override int FindHighlightedIndex (string searchText, System.Collections.IList filteredItems, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
{
return -1;
}
}
<telerik:RadAutoCompleteBox x:Name="textBox_Search"
ItemsSource="{Binding AutoCompleteList}"
SelectionMode="Single"
TextSearchMode="Contains"
BorderThickness="0"
HighlightBehavior="{StaticResource NoSuggestionItemHighlightBehavior}"
SearchText="{Binding SearchText, Mode=TwoWay}">
7 Answers, 1 is accepted
Thank you for your interest in RadAutoCompleteBox control.
I try to reproduce this behavior using custom HighlightBehavior but to no avail. Attached to this reply is the sample project which I used to test your scenario. In the attached project I have subscribed to KeyDown event of the control. Depending on which buttons are pressed () I am changing the ItemsSource so I can simulate your scenario and no item is highlighted.
Give this project a try and let me know if I am missing something from your implementation so I can reproduce this behavior on my side.
Regards,
Dinko
Progress Telerik
Hi Dinko,
Thanks for looking in to the issue I am facing.
I can still reproduce it in your sample code.
I kept only one suggention in textbox_Search_keyDown for A key down (Please see screen shot attached) and I executed the sample app and pressed 'A' in autoCompleteBox, I got one suggestion which was selected by default, even though we are returning -1 from CustomHighlightBehavior.
Also, since one option is selected by default, that selected string appears in the autoCompleteText Box. We want to remove this behavior. Please refer attached screenshot.
Thanks,
Prasad.
Indeed this is strange behavior as I wasn't able to reproduce it on my side. The highlight should not appear after you have set the custom HighlightBehavior to the HighlightBehavior property of the RadAutoCompleteBox. You can double check if this property is set in your main application.
<
Window.Resources
>
<
local:MyHighlightBehavior
x:Key
=
"MyHighlightBehavior"
/>
</
Window.Resources
>
<
Grid
>
<
telerik:RadAutoCompleteBox
x:Name
=
"textBox_Search"
ItemsSource
=
"{Binding Countries}"
DisplayMemberPath
=
"Name"
SelectionMode
=
"Single"
TextSearchMode
=
"Contains"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
Width
=
"200"
BorderThickness
=
"1"
KeyDown
=
"textBox_Search_KeyDown"
HighlightBehavior
=
"{StaticResource MyHighlightBehavior}"
SearchText
=
"{Binding SearchText, Mode=TwoWay}"
/>
</
Grid
>
Can you confirm that the only modification which has done to the project attached to my previous reply is to just leave one item when you press "A" key from the keyboard?
Regards,
Dinko
Progress Telerik
Hello!
Any update on this ?
Please advise.
Thanks!
Regards, Dmitry.
Hi Dmitry,
As I wasn't able to reproduce this behavior, may I ask you to confirm that you are reproducing it on your side? Have you tried the attached project from my previous reply? If you are reproducing it in the sample project, can you share the exact steps? Any additional information will be highly appreciated.
Regards,
Dinko
Progress Telerik
Hello Dinko!
Yes I have pretty same XAML markup.
If you will change your collection (Countries) to have just a single record, you will see same result as Prasant mentioned in screenshot in post in above.
PS: Just in case. Version of telerik is 2014.3.1202.45
Please advise.
Thanks!
Regards, Dmitry.
Hello Dmitry,
Thank you for specifying the version which you are using. You are right that this behavior is reproducible in the specified version. However, it is not observed in our latest releases. That is why I would recommend you to upgrade to our most recent version of our controls. This way, you can take advantage of the newest features and bug fixes (which include the one here) in our UI for WPF suite.
Regards,
Dinko
Progress Telerik