I have the following scenario:
I have an expander control that is bound to the collection using an item list and inside each list is a sub list.
What is the best practice for refreshing the view to show the updated object. What I was doing to refresh the collection was the following:
ObservableCollection<ProjectDto> projects = new ObservableCollection<ProjectDto>();
Projects.ForEach(projects.Add);
Projects.Clear();
projects.ForEach(Projects.Add);
This makes the expander collapse as I think it is being bound to a new collection.
What is the relationship between projects (little p) and Projects (capital P) - why two lists? What does your binding look like?
EDIT
Let's assume for discussion that Projects is an ObservableCollection, and is what is bound to your UI, and that projects is either a temporary, domain model, or backend list that you use to assemble and prepare (sort, validate, etc.) DTOs for presentation. In this case, projects can just be a List, and you can every time you do Projects = new ObservableCollection(projects) your bound UI items collection should refresh.
Berryl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.