You can’t do this in Binding the Data for ListBox

During the Binding of the Data to the ListBox , it is only possible to bind the public properties to the ItemSource .

If you are binding the public fields to the Listbox , you might not see the actual data 🙁

For example

public class Movie
{
public string Name;
public string Actor;
}

and create a List of Movie and assign it to the ItemSource Property of the Listbox , you will see the Listbox will be empty .

To get it to work , you should modify this to the Property like

public class Movie
{
public string Actor { get; set; }
public string Name { get; set; }
}

Leave a Reply