Sorting a List by its property renames all the objects in the List

44 Views Asked by At

I have a class called Task in which I have properties like Date, Id, priority and Name. I have a list where I store objects of this class. The problem is that when I do the sorting and then display it in my Listview (I am working in WPF framework coz it is a part of the assigment) all the tasks get renamed tothe same thing (TODO-list.task.Task) from their original name and I have no idea if the sorting actually worked.

I use this to sort the list:

List<Task> sort_by_date = tasks.OrderBy(x => x.Date).ToList();

And then write it out to list view like this:

MainWindow.withDate.Item.Clear();
MainWindow.withDate.ItemsSource = sort_by_date;

EDIT: Already figured it out...it was a small thing in writing out teh listview

0

There are 0 best solutions below