I created a Xamarin App that utilizes a WebView2 control. the control displays a lot of HTML code.
I am able to scroll vertically, but I would like to add the functionality of PgUp and PgDn based on a swipe left or right
I thought i would be able to catch a Swipe event like this:
SwipeGestureRecognizer swipe = new SwipeGestureRecognizer {Direction = SwipeDirection.Left | SwipeDirection.Right }; swipe.Swiped += OnSwiped; webView.GestureRecognizers.Add(swipe);
OnSwipe is never called. (Tested in both UWP and Android)
(I am also not getting any errors when this code runs
Am i leaving anything out?
Thanks
Answers
In android, you can create a custom renderer for your webwiew. then add
SetOnTouchListener
forWebview
.Here is running GIF.
thank you for this reply.
unfortuantely, i do not understadn how to implement it. I seem to be missing libraries, such as for classes: WebViewRenderer, Control, GestureDetector , Java.Lang.Object, Android.Views.GestureDetector.IOnGestureListener, etc.
You do not missing libraries, you should create an custom renderer for your webview like following link. Above code is related to the android platform.
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview#create-the-custom-renderer-on-android