How Can I Update a WPF ListView?

  • Thread starter Thread starter EagleRed
  • Start date Start date
E

EagleRed

I have an application with a WPF ListView that is bound to a
List<CustomObject>. I do some processing and the add a new CustomObject
instance to the List. How can I display the ListView with the newly added
item? I tried resetting the ItemSource and that did not work.

As always, any input will be helpful.

Thanks,
Eagle
 
Sometimes it is good to find an answer to your own question. A way to do
this is to set teh ItemSource to null and then reassign it. The follow
snippet shows and example with a WPF ListView, myListView with a
List<CustomObject>, customObjectList, set as the ItemSource.

customObjectList.Add(newCustomObject);
myListView.ItemSource = null;
myListView.ItemSource = customObjectList;
 
Back
Top