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

Text search on listbox with DataTemplate

2 Answers 313 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Veteran
Michael asked on 09 Feb 2018, 12:52 AM

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 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 13 Feb 2018, 11:35 AM
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.
0
Michael
Top achievements
Rank 1
Veteran
answered on 19 Feb 2018, 09:58 PM
Thanks Vladmir, it's working nicely with build 2018.1.205
Tags
ListBox
Asked by
Michael
Top achievements
Rank 1
Veteran
Answers by
Vladimir Stoyanov
Telerik team
Michael
Top achievements
Rank 1
Veteran
Share this question
or