RadAutoCompleteBox

1 Answer 29 Views
AutoCompleteBox
Artur
Top achievements
Rank 1
Artur asked on 04 Jun 2024, 09:40 PM
I am using the RadAutoCompleteBox control in a WPF application and need assistance with configuring it to search for items based on the Name property, but display the values from the Key property.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 05 Jun 2024, 01:16 PM

Hello Artur,

To achieve this requirement, you can set the DisplayMemberPath property to "Key" and the TextSearchPath property to "Name".

The following code snippets show a sample implementation of this suggestion:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        ObservableCollection<Item> items = new ObservableCollection<Item>()
        {
            new Item(){ Name = "Name 1", Key = "Key 1" },
            new Item(){ Name = "Name 2", Key = "Key 2" },
            new Item(){ Name = "Name 3", Key = "Key 3" },
            new Item(){ Name = "Name 4", Key = "Key 4" },
            new Item(){ Name = "Name 5", Key = "Key 5" },
        };

        this.autoCompleteBox.ItemsSource = items;
    }
}

public class Item
{
    public string Name { get; set; }
    public string Key { get; set; }
}
<Grid>
    <telerik:RadAutoCompleteBox x:Name="autoCompleteBox"
                                DisplayMemberPath="Key"
                                TextSearchPath="Name"/>
</Grid>

The produced result is as follows:

I have also attached a sample project for you to test.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
AutoCompleteBox
Asked by
Artur
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or