WebView scrolled event

Dear all community,

I need to know when the user has ended the scroll on a webview displaying a agreement, to display an "Accept" only when the user has read this.

Here is my webview (axml) :

  <WebView x:Name="webView" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
    <WebView.Source>
      <HtmlWebViewSource Html="{Binding Content}" />
    </WebView.Source>
  </WebView>

How can I do that ?..
I'm new on Xamarin, thanks for your help ;)

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Since Xamarin.Forms does not provide an event for when the WebView scrolls, you will need to create a custom renderer for the WebView in each platform specific project and then implement the scrolling handler in the custom renderer.

    I've attached a quick sample that works in iOS, but on Android the Android.WebKit.WebView.ContentHeight is not returning a correct value so it is not working yet on Android. The scroll event is handled, but without an accurate content height I do not know how to tell when it hits the end. If your form won't change height and you can measure what that height is, then you may be able to check the ScrollY position against a known content height.

Sign In or Register to comment.