Skip to content

Instantly share code, notes, and snippets.

@wtuts
Created June 23, 2014 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtuts/23e9380ee42f3a869d3c to your computer and use it in GitHub Desktop.
Save wtuts/23e9380ee42f3a869d3c to your computer and use it in GitHub Desktop.
Data binding in listbox
public void firstmethod()
{
//create a list of Resultclass
List<Resultclass> mylist = new List<Resultclass>();
for (int i = 0; i < 8; i++)
{
//Create a new object of Result class
Resultclass obj = new Resultclass();
//add the corresponding data from the sample array
obj.name = studentnames[i];
obj.marks = studentmarks[i];
//add the object into the list created
mylist.Add(obj);
}
//Set the itemsource of the mylistbox created
mylistbox.ItemsSource = mylist;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment