Quick answer: ListView doesn’t observe its source. Call Rebuild() after structural changes (add/remove), RefreshItems() after content-only changes, and reassign itemsSource if you replaced the list entirely.
An inventory ListView keeps showing the old items after you add a new one to the backing List. Adding to the list doesn’t notify the view.
ListView Is Pull-Based
UI Toolkit’s ListView pulls from itemsSource when told to. Mutating the source list doesn’t trigger anything — you must call the appropriate refresh.
Pick the Right Method
- Rebuild(): full rebuild — size, items, bindings. Use after add/remove/reorder.
- RefreshItems(): re-runs bindItem on existing rows. Use when underlying data changed but the list size didn’t.
- RefreshItem(int index): rebinds one row.
Replaced the List?
If you swap to a new List instance, also reassign listView.itemsSource = newList. The view keeps a reference to the old one otherwise.
Wrap It
void AddItem(Item item)
{
_items.Add(item);
listView.RefreshItems(); // or Rebuild() if you need size update
}
Put the refresh next to the mutation so they can’t drift apart.
Verifying
Add, remove, reorder items — the view updates immediately. Scroll position is preserved when possible (Rebuild may reset; RefreshItems usually doesn’t).
“ListView doesn’t observe; you tell it. Refresh after every change — ideally in the same method.”
Hide mutation behind a small adapter class that always pairs the list change with the refresh — callers can’t forget.