Xamarin.Forms UWP DatePicker Max/Min Date Bug RRS feed

  • Question

  • User344275 posted

    I have noticed that on UWP when creating a xamarin.Forms DatePicker with a Max and Min date set, the DatePicker will allow a date to be entered outside of that range. Once the out of range date is confirmed in the picker the Binding will then snap back to the boundary of the min or max but the UI will not update to show that the date has been changed.

    So say I have a date range of January 1st 2020 through June 30th 2020 and I choose a date of July 1st 2020, the Date picker will allow me to confirm this date but then behind the scenes will set the Binding value back to June 30th 2020. However, the Date picker UI will not update and will still show July 1st 2020.

    There is already an issue filed for this bug here

    But I am in need of a fix while it is still in development, has anyone found a workaround for this?

    Monday, March 9, 2020 7:47 PM

All replies

  • User371688 posted

    the DatePicker will allow a date to be entered outside of that range

    When you say 'Max and Min date set', do you mean the Max and Min date or the MaxYear and MinYear? In uwp,when we check Properties of DatePicker, there is no such property of Max and Min date.

    Tuesday, March 10, 2020 9:29 AM
  • User344275 posted

    Thanks for the response. Yea, I'm aware that the uwp date picker only allows a min and max year. I'm hoping that they replace it with a calendar view that will support a max and min date. But the fact remains that the xamarin control calls it a min and max date and in uwp apparently still does something to snap you back into the bounds of the range you input, it just doesn't update the ui. I'm fine with this implementation of it as long as the ui updates when you click away from the control. So that's what I'm trying to see, has anyone found a work around for that bug

    Tuesday, March 10, 2020 12:16 PM
  • User371688 posted

    If it is convenient for you , could you please post a basic demo or some code snippet so that we can help you better?

    Thursday, March 12, 2020 9:01 AM
  • User344275 posted

    Sorry it took me a bit to get some time to whip up a demo but here you go: https://github.com/JCookVF/DatePickerDemo.git

    You'll notice in the demo if you run on uwp it has a datepicker and a label underneath both bound to the Date property on the vm. When a date outside the Max min range is entered it will snap the bound value back to the closest min max value. However, the datepicker will not update its ui, but the label underneath will.

    Monday, March 16, 2020 3:42 PM
  • User371688 posted

    We tested your code in uwp platform, for this question, when we set the date and exceed the range(MaximumDate and MinimumDate), the interface will be updated only if the Year value changes.

    And these are the only two properties MaxYear and MinYear in UWP,which all relative to Year.So this is should be the reason for this question.

    So we can only wait for Xamarin developers to update the latest features in UWP.

    Tuesday, March 17, 2020 10:15 AM
  • User344275 posted

    But in my Demo the date max and min range are confined to the same year. There would be no changing of the year. Yet, you see that the actual bound Date does get automatically set back to the Max or Min date if you exceed the range, right? Would there not be a way to create a custom renderer that would just force update the UI when date gets automatically corrected?

    Tuesday, March 17, 2020 3:12 PM
  • User371688 posted

    We will consult with our developers and get back to you.

    Friday, March 20, 2020 9:31 AM