TextSearchPath and DisplayMemberPath differences?

4 posts, 0 answers
  1. Manuel
    Manuel avatar
    5 posts
    Member since:
    Dec 2014

    Posted 18 Dec 2014 Link to this post

    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?
  2. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 19 Dec 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Manuel
    Manuel avatar
    5 posts
    Member since:
    Dec 2014

    Posted 19 Dec 2014 Link to this post

    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?
  5. Polya
    Admin
    Polya avatar
    199 posts

    Posted 23 Dec 2014 Link to this post

    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.

     
Back to Top