C# – How to force a WPF ListView to Requery its ItemSource

c++listviewrefreshwpfxml

I'm rewriting its XML itemSource on the fly and want it to use the new data right away…

Best Solution

You should use an ObervableCollection. When this collection is updated, the ListView is updated.

But if for any reason you donĀ“t want to use one, use:

listView.InvalidateProperty(ListView.ItemsSourceProperty);

or

listView.ItemsSource = listView.ItemsSource;

Check A more elegant ListView requery for more info.