How to scroll automatically in Xamarin.Forms

2019-06-08 09:58发布

问题:

In Xamarin.Android I can scroll automatically at the end of my image:

scrollView.Post(() => scrollView.FullScroll(FocusSearchDirection.Right));

How can I do the same in Xamarin.Forms?

回答1:

ScrollView has 2 methods available to accomplish this:

public Task ScrollToAsync (double x, double y, bool animated)
public Task ScrollToAsync (Element element, ScrollToPosition position, bool animated)

https://developer.xamarin.com/api/type/Xamarin.Forms.ScrollView/#Public_Methods



回答2:

In a ListView you can use ScrollTo , in a ScrollView you can use ScrollToAsync for position or ScrollToAsync for a element