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

8 posts, 0 answers
  1. Prasad
    Prasad avatar
    2 posts
    Member since:
    Nov 2017

    Posted 28 Nov 2017 Link to this post

    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}">

  2. Dinko
    Admin
    Dinko avatar
    952 posts

    Posted 01 Dec 2017 Link to this post

    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 (A,B,C) 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.
  3. Prasad
    Prasad avatar
    2 posts
    Member since:
    Nov 2017

    Posted 07 Dec 2017 in reply to Dinko Link to this post

    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.

  4. Dinko
    Admin
    Dinko avatar
    952 posts

    Posted 11 Dec 2017 Link to this post

    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 allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Dmitry
    Dmitry avatar
    2 posts
    Member since:
    Oct 2019

    Posted 14 Oct in reply to Dinko Link to this post

    Hello!

    Any update on this ?
    Please advise.

    Thanks!

    Regards, Dmitry.

  6. Dinko
    Admin
    Dinko avatar
    952 posts

    Posted 17 Oct Link to this post

    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.
  7. Dmitry
    Dmitry avatar
    2 posts
    Member since:
    Oct 2019

    Posted 17 Oct in reply to Dinko Link to this post

    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.

     

  8. Dinko
    Admin
    Dinko avatar
    952 posts

    Posted 18 Oct Link to this post

    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.
Back to Top