你如何强制WPF的ListView重新查询它的ItemSource? [英] How do you force a WPF ListView to Requery its ItemSource?

查看:568
本文介绍了你如何强制WPF的ListView重新查询它的ItemSource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重写飞其XML的ItemSource,并希望它使用新的数据的时候了......

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

推荐答案

您应该使用ObervableCollection。当这个集合更新,在ListView更新。

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);

listView.ItemsSource = listView.ItemsSource;

检查<一href=\"http://stackoverflow.com/questions/1406542/a-more-elegant-listview-requery\">http://stackoverflow.com/questions/1406542/a-more-elegant-listview-requery获取更多信息。

这篇关于你如何强制WPF的ListView重新查询它的ItemSource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆