Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: listview display recently added items on top instead of bottom

Tags:

c#

wpf

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 ?

Thanks

like image 215
ravedome Avatar asked Apr 19 '11 22:04

ravedome


1 Answers

Use Insert instead of Add :

collection.Insert(0, newItem);

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.

like image 194
Thomas Levesque Avatar answered Oct 23 '22 03:10

Thomas Levesque