Q:

Xamarin.Forms Android DatePicker/TimePicker button listener

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?

A:

I need to know if a user tapped on the "cancel" or on the "ok" button in a date/time picker of an xamarin.Forms Android app.

With Xamarin.Form's DatePicker, you can't do that. Xamarin.Forms.DatePicker is renderered into an EditText control. The pop up DatePickerDialog is unfortunately not exposed to user. You can see that from Source Codes of DatePickerRenderer.
So if you really want to detect the OK/Cancel button click events. You need to implement your own DatePickerRenderer according to the source codes.

