简体   繁体   中英

Scroll Xamarin Forms listview when using bindings

I am brand new to Xamarin and MVVM so this may be a stupid question.

I have a ListView which is populated using an observable collection, that collection is added to by a viewmodel.

What i want to do is when an item is added I want to scroll the listview to the bottom however the viewmodel does not have visibility to the listview control.

How can i get my listview to scroll when a new item is added to its collection?

I think you can use MessagingCenter.

In your ViewModel, when you Add the new Item you can MessagingCenter.Send a message, and in your Page you can subscribe to this message. When you receive this message in your Page, you can ScrollTo your ListView

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM