如何在 WPF 中刷新 ListView [英] How I Can Refresh ListView in WPF

查看:31
本文介绍了如何在 WPF 中刷新 ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WPF 并将记录一一添加到 listview.ItemsSource.我的数据会在所有数据都加进去的时候出现,但是我想把数据一一加起来展示出来.

Hi I am using WPF and adding records one by one to the listview.ItemsSource. My data will appear when all the data is included, but I want to show the data as it is added one by one.

我使用了 ListView.Item.Refresh() 但它没有用.

I used ListView.Item.Refresh() but it didn't work.

有什么办法吗?

推荐答案

如果您在任何其他情况下仍需要刷新 ListView(假设您需要在将所有元素添加到 ItemsSource 后更新一次)所以你应该使用这种方法:

If you still need to refresh your ListView in any other case (lets assume that you need to update it ONE time after ALL the elements were added to the ItemsSource) so you should use this approach:

ICollectionView view = CollectionViewSource.GetDefaultView(ItemsSource);
view.Refresh();

这篇关于如何在 WPF 中刷新 ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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