How do you force a WPF ListView to Requery its ItemSource?

故事扮演 提交于 2019-12-05 15:24:41
Oscar Foley

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.

hmm...

listView.ItemsSource = listView.ItemsSource?

or you could trigger the PropertyChanged event on the property of your viewmodel in case you are using MVVM.

ListView.DataBind(); MSDN

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!