Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Touch Events in Xamarin.Forms?

$
0
0

Am I crazy or is there no way to get at basic touch events (up/down/move) in Xamarin Forms?

It's trivial to add a custom renderer for a control and then access the touch events in the Android/iOS implementation. Problem is this results in a lot of repeated code if you have multiple types of controls that you need to get touch events for (plus the need for customer renderers that I wouldn't otherwise need).

I tried making a "touch service" that would take in a VisualElement and the platform implementation would wire up all the listeners on that element. The problem is I can't figure out how to get from a VisualElement to a native control so that I can subscribe to touch events. For instance, in my Android implementation I tried RendererFactory.GetRenderer(visualElement).ViewGroup.Touch += (s, e) { /* touch handler code */ }, but that never gets triggered.


Viewing all articles
Browse latest Browse all 58056

Trending Articles