Gesture Recognizers with Xamarin.Forms
Why gestures ?
Some controls does not have support click event. In order to achieve add the below code this will enabling click event in the controls..Gestures are mainly of 3 types
- Tap Gesture Recognizer
- Pinch Gesture Recognizer
- Pan Gesture Recognizer
1) Tap Gesture Recognizer
var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += tapGestureRecognizer_Tapped; Controler_Name.GestureRecognizers.Add(tapGestureRecognizer); void tapGestureRecognizer_Tapped(object sender, EventArgs e) { ........//Code here }
2) Pinch Gesture Recognizer
var pinchGestureRecognizer = new PinchGestureRecognizer(); pinchGestureRecognizer.PinchUpdated += pinchGestureRecognizer_PinchUpdated; Controler_Name.GestureRecognizers.Add(pinchGestureRecognizer); void pinchGestureRecognizer_PinchUpdated(object sender, PinchGestureUpdatedEventArgs e) { ........//Code here }
3) Pan Gesture Recognizer
var panGestureRecognizer = new PanGestureRecognizer(); panGestureRecognizer.PanUpdated += panGestureRecognizer_PanUpdated; lbLatitude.GestureRecognizers.Add(panGestureRecognizer); void panGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e) { ........//Code here }
Comments
Post a Comment