WPF:ListView控件显示最近添加的顶部而不是底部项目 [英] WPF: listview display recently added items on top instead of bottom
本文介绍了WPF:ListView控件显示最近添加的顶部而不是底部项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了一个集绑定到ListView。这个系列获得项目增加每4-5秒的新项目将自动在ListView底部加入。所以,如果你会看到最新的项目,那么你需要向下滚动到下
I got a collection bind to a listview. This collection gets items added every 4-5 seconds and new items will automatically be added in bottom of the listview. So if you gonna see newest items then you need to scroll down to the bottom.
我的问题是:
是否有可能像扭转列表视图使新的最新项目在底部最早的项目是在顶部和?
My question is: is it possible to like reverse the listview so the new newest items are on top and oldest items in bottom ?
感谢
推荐答案
使用插入
而不是添加
:
collection.Insert(0, newItem);
请注意,它比添加
更慢,因为它有1个职位转移的所有项目。如果该列表是非常大的,可能是一个问题。
Note that it's slower than Add
since it has to shift all items by 1 position. It might be an issue if the list is very big.
这篇关于WPF:ListView控件显示最近添加的顶部而不是底部项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文