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

TextSearchPath and DisplayMemberPath differences?

3 Answers 321 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 18 Dec 2014, 09:22 AM
Hi,

I have a problem when setting my DisplayMemberPath:

<t:RadAutoCompleteBox x:Name="AutoCompleteBox" Grid.Row="2" Grid.ColumnSpan="3"
                                         ItemsSource="{Binding Suggests}"
                                        SearchText="{Binding TextSearch, Mode=TwoWay}"
                                        SelectedItem="{Binding SelectedSuggest, Mode=TwoWay}"
                                    TextSearchPath="SearchPath" DisplayMemberPath="Name">
                <t:RadAutoCompleteBox.DropDownItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Name}" />
                            <TextBlock Text=" - " />
                            <TextBlock Text="{Binding Code}" />
                        </StackPanel>
                    </DataTemplate>
                </t:RadAutoCompleteBox.DropDownItemTemplate>
            </t:RadAutoCompleteBox>


In the code above, all is working fine, except that when i have selected an item, the text displayed is the one in my SearchPath property, and not the one in my Name property.
What did i do wrong?

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 19 Dec 2014, 03:43 PM
Hello Manuel,

We tested the provided code snippet of with the latest version of Telerik controls (2014.3.1202) and everything works as expected - the DisplayMemberPath gets visualized when item is selected. The TextSeachPath property is used for the filtering of the items while the DisplayMemberPath contains the property that will be displayed as soon as an item is selected. However, this is only valid if the SelectionMode property is set to Multiple (which is by default). If it is set to Single the property that will be visualized when a selection is made will be the one that is set to the TextSearchPath.

What we could recommend you is to upgrade to the latest version of the controls if you're using an older one.

We hope this will help you.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Manuel
Top achievements
Rank 1
answered on 19 Dec 2014, 04:05 PM
Hello,

I understand what happened so.

I need to use single selection mode.
There is a way to handle the feature with single selection mode?
0
Polya
Telerik team
answered on 23 Dec 2014, 03:20 PM
Hello Manuel,

As you are using Single SelectionMode I suggest creating a custom FilteringBehavior and overriding its FindMatcingItems method in order to implement a custom filtering by a different property of the objects.
You can supply the TextSearchPath in the custom FilteringBehavior. This way you don't have to supply it in xaml and the DisplayMemberPath will be used to visualize the SelectedItem.

Please find attached a sample project demonstrating this approach.
Hopefully this helps and is suitable for your scenario.

Regards,
Polya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
AutoCompleteBox
Asked by
Manuel
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Manuel
Top achievements
Rank 1
Polya
Telerik team
Share this question
or