datePicker : maximumdate and minimumdate aren't working correctly when customizing the picker.

I have been trying to use the date picker with

if I choos a value greter the MaximumDate and less then MinimumDate it's working perfectly but the effect

is not working when having a renderer datePicker

am I missing something, or is it a bug from xamarin??

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    I create a custom renderer for picker.I set the following code.

          public class DatePickerCtrlRenderer: DatePickerRenderer
    {
        public DatePickerCtrlRenderer(Context context) : base(context)
        {
        }
    
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
        {
            base.OnElementChanged(e);
    
            MyPicker element = Element as MyPicker;
            element.MinimumDate = new DateTime(2019, 9, 11);
            element.MaximumDate = new DateTime(2019, 9, 20);
        }
    }
    

    It work normally, you can refer to this screenshot.

Sign In or Register to comment.