Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Custom Objects in RadAutoCompleteBox for Windows Phone

DZone's Guide to

Using Custom Objects in RadAutoCompleteBox for Windows Phone

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

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;       �
}   �
}



 

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}