This is a migrated thread and some comments may be shown as answers.

RadAutoCompleteBox HighlightBehavior not working. One item is highlighted even if FindHighlightedIndex is returning -1.

7 Answers 65 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Prasad
Top achievements
Rank 1
Prasad asked on 28 Nov 2017, 12:43 PM

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

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 01 Dec 2017, 07:25 AM
Hello Prasad,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Prasad
Top achievements
Rank 1
answered on 07 Dec 2017, 07:33 AM

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.

0
Dinko | Tech Support Engineer
Telerik team
answered on 11 Dec 2017, 11:54 AM
Hi 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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Dmitry
Top achievements
Rank 1
answered on 14 Oct 2019, 10:30 AM

Hello!

Any update on this ?
Please advise.

Thanks!

Regards, Dmitry.

0
Dinko | Tech Support Engineer
Telerik team
answered on 17 Oct 2019, 07:09 AM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dmitry
Top achievements
Rank 1
answered on 17 Oct 2019, 07:24 AM

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.

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 18 Oct 2019, 12:27 PM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
Prasad
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Prasad
Top achievements
Rank 1
Dmitry
Top achievements
Rank 1
Share this question
or