Mobile Zone is brought to you in partnership with:

Senthil Kumar is a Software Engineer who has around 3 years of experience in IT industry. He is currently working as a Software Engineer in Bangalore and works mainly on the Windows or Client Development technologies and has good working experience in C#/.NET, Delphi, Winforms and SQL Server. He is also a Microsoft Technology Certified Professional in ASP.NET. He Blogs at http://www.ginktage.com and http://www.windowsphonerocks.com. He enjoys learning as much as he can about all things related to technologies to get a well-rounded exposure of technologies that surround him. Senthil completed his Master of Computer Applications from Christ College (Autonomous), Bangalore in the year 2009 and is a MCA Rank Holder. He has passion for Microsoft technologies especially Windows Phone development. You can connect with him on Twitter at (http://twitter.com/isenthil) , on Facebook at (http://www.facebook.com/kumarbsenthil) and his blog (www.ginktage.com). Senthil is a DZone MVB and is not an employee of DZone and has posted 118 posts at DZone. You can read more from them at their website. View Full User Profile

Using Custom Objects in RadAutoCompleteBox for Windows Phone

04.26.2012
| 2238 views |
  • submit to reddit

In one of my earlier blog posts, I talked about RadAutoCompleteBox showing how to display suggestions using a List of strings.

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

To put it simply, Telerik’s Support Team is 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 a 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;       �
}   �
}



 

Published at DZone with permission of Senthil Kumar, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)