I need to know if a user tapped on the Cancel or Ok button
in a Date/Time picker of an xamarin.Forms
Android app.
I have tried to add a function to the Click event but this is never triggered.
This is my code (similar for the TimePicker):
using Android.Content;
using MyApp.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using MyApp.Models;
using Java.Util;
[assembly: ExportRenderer(typeof(DatePicker), typeof(DatePickerCustomRenderer))]
namespace MyApp.Droid {
public class DatePickerCustomRenderer : DatePickerRenderer {
public DatePickerCustomRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e) {
base.OnElementChanged(e);
Locale locale = new Locale(Utente.FormatoPerDateTimePicker);
Control.TextLocale = locale;
Control.Click += Control_Click;
}
private void Control_Click(object sender, System.EventArgs e) {
// This function is never called :(
throw new System.NotImplementedException();
}
}
}
How can I do this?