问题
I'm rewriting its XML itemSource on the fly and want it to use the new data right away...
回答1:
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.
回答2:
hmm...
listView.ItemsSource = listView.ItemsSource?
or you could trigger the PropertyChanged event on the property of your viewmodel in case you are using MVVM.
回答3:
ListView.DataBind(); MSDN
来源:https://stackoverflow.com/questions/1111338/how-do-you-force-a-wpf-listview-to-requery-its-itemsource