I'm trying to implement chat stream view using Xamarin.Forms ListView and ObservableCollection
. Chat stream is reverse in its nature - instead of growing down it grows up. Usually when you want to lazy load data using ObservableCollection
and ListView
you would load new data when user reaches the end and insert it in at the end of ObservableCollection
, this will update the ListView
just okay and the items will appear at the end of it. In chat stream user scrolls from bottom to top, and when reaching top I should load new chat messages and insert them at the beginning of ObservableCollection
. It does insert and updating list items works fine. However, the list scroll position isn't preserved on the last message that user was on before loading new messages. Instead it's scrolled to the top of the list view. How can I customize the ListView to preserve the scroll position and insert items at the top of the list view?
↧
Preserve ListView scroll position when inserting rows at the top.
↧