Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin.Forms Android DatePicker/TimePicker button listener

$
0
0

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.

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?

Thank you!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>