I have a problem with list and listview.
I started a project and added a listview. After this I created a class which has two elements e.g. key1 and key2 both are strings.
I bind the text of the itemTemplate of the listbox to this keys and everything is fine.
then I set listbox1.ItemsSource = data;
and data is: List<OwnListData> data = new List<OwnListData>();
everything is displayd.
but the problem is, when I change an item of data, the list does now show any changes. How do I get the listview to refresh`?
EDIT: a quick and dirty solution is to make
listbox1.ItemsSource = null;
listbox1.ItemsSource = data;
after each change, but this is not the nice way
Use
ObservableCollection<OwnListData>instead ofList<OwnListData>. I’ve faced this problem too.It seems that Lists and Enumerables can’t be used with ListBox because they don’t update the UI.
Hope it helps