HomeWindowsTelerik RadControls for Windows Phone – Article #7 – Using Custom Objects in RadAutoCompleteBox

Telerik RadControls for Windows Phone – Article #7 – Using Custom Objects in RadAutoCompleteBox

In one of my earlier blog post , i explained about RadAutoCompleteBox showing how to display suggestions using a List of string .

I had a requirement to bind custom object to the Suggestion List to the RadAutoCompleteBox and had to take help of the Telerik Support Team to get it done.

To put it simple , Telerik’s Support Team is simply super .

To bind the Custom Business Objects , you should follow 3 steps

1. Set the SuggestionsSource to the List of Custom Objects

2. Set the FilterKeyPath

3. Create SuggestionItemTemplate and DataTemplate and bind the property that should be displayed as suggestion.

Below is a sample sourcecode that uses Custom Objects to display Suggestion .

<telerikInput:RadAutoCompleteBox Height="70" HorizontalAlignment="Left" Margin="17,31,0,0" Name="radAutoCompleteBox1" Text="" 
VerticalAlignment="Top" Width="429" FilterKeyPath="Name"  >
<telerikInput:RadAutoCompleteBox.SuggestionItemTemplate>
<DataTemplate>                     
<TextBlock Text="{Binding Name}"/>                 
</DataTemplate>                 
</telerikInput:RadAutoCompleteBox.SuggestionItemTemplate>             
</telerikInput:RadAutoCompleteBox>
public partial class MainPage : PhoneApplicationPage     
{         
// Constructor         
public MainPage()         
{             
InitializeComponent();             
radAutoCompleteBox1.SuggestionsSource = Data.GetSuggestions();         
}      
}     
public class Employee     
{         
public string Name         
{             
get;             
set;         
}

public string ID         
{             
get;             
set;         
}

}     
public static class Data     
{         
public static List<Employee> GetSuggestions()         
{             
List<Employee> Names = new List<Employee>();             
Names.Add(new Employee { Name = "Vijay", ID = "1" });             
Names.Add(new Employee { Name = "Senthil", ID = "2" });             
Names.Add(new Employee { Name = "Surya", ID = "3" });             
Names.Add(new Employee { Name = "Norton", ID = "4" });             
Names.Add(new Employee { Name = "Sandy", ID = "5" });             
Names.Add(new Employee { Name = "Saravan", ID = "6" });             
Names.Add(new Employee { Name = "Sunil", ID = "7" });            
 return Names;         
}     
}
Telerik RadControls for Windows Phone – Article #7 – Using Custom Objects in RadAutoCompleteBox
Telerik RadControls for Windows Phone – Article #7 – Using Custom Objects in RadAutoCompleteBox

Leave a Reply

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...