Text search on listbox with DataTemplate

3 posts, 0 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Sep 2017

    Posted 08 Feb 2018 Link to this post

    Adding a datatemplate to a listbox seems to break the automatic "startswith" search. I was hoping that overriding ToString() might help, but it doesn't seem to. 

    Can anybody point me in the right direction?

     

    Thanks

     

    class ItemVM
        {
            public StyleDefinition Style { get; set; }
            public string TagText { get; set; }

            public override string ToString()
            {
                return Style.Description;
            }
        }

    <telerik:RadListBox 
                SelectionMode="Single"
                TextSearchMode="StartsWith">
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate>
                        <DockPanel>
                            <TextBlock Text="{Binding Style.DisplayName}" />
                            <TextBlock Text="{Binding TagText}" HorizontalAlignment="Right"/>
                        </DockPanel>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
            </telerik:RadListBox>

     


  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    405 posts

    Posted 13 Feb 2018 Link to this post

    Hello Michael,

    Thank you for the provided code snippet. 

    We had an issue related to the StartsWith TextSearchMode which is logged in our feedback portal. The fix for that issue is available with our latest internal build version: 2018.1.205 and will also be available with R1 2018 SP2 Release. You can download the latest internal build from the Download section of your Telerik account under Latest Internal Builds.

    I tested the described behavior with the 2018.1.205 version build and it is working as expected. I am attaching a sample project demonstrating this for your reference. I also included the dll from that build in the libs folder for your convenience.

    Please note that between typing different letters, you have to wait 800 ms before the typed text is reset. You can change that by setting the TextSearch.AutoCompleteTimeout property in the MainWindow of your application like so:
    Telerik.Windows.Controls.TextSearch.AutoCompleteTimeout = TimeSpan.FromSeconds(2);

    I hope this helps.

    Regards,
    Vladimir Stoyanov
    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. Michael
    Michael avatar
    18 posts
    Member since:
    Sep 2017

    Posted 19 Feb 2018 in reply to Vladimir Stoyanov Link to this post

    Thanks Vladmir, it's working nicely with build 2018.1.205
Back to Top