How to get WPF ListView to request its ItemSource?

I rewrite its XML itemSource on the fly and want it to use the new data right away ...

+4
source share
3 answers

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

But if for some reason you do not want to use it, use:

listView.InvalidateProperty(ListView.ItemsSourceProperty); 

or

 listView.ItemsSource = listView.ItemsSource; 

Read more about More elegant ListView query for more information.

+4
source

hmm ...

 listView.ItemsSource = listView.ItemsSource? 

or you can raise the PropertyChanged event in the viewmodel property if you are using MVVM.

+1
source

ListView.DataBind (); MSDN

-1
source

All Articles