maui icon indicating copy to clipboard operation
maui copied to clipboard

Datepicker Two-Way Binding On Android

Open EmberLynn opened this issue 2 years ago • 2 comments

Description

I'm having an issue with DatePicker's behavior and am going to assume it is a bug.

Here is what our DatePicker looks like in XAML:

datepicker

DateValue is a property that belongs to the CustomFormField model. A DateValue of null is an acceptable value within the CustomFormField. When the picker renders on screen, it displays today's date by default (when TextValue starts at null):

default date

If you click on the DatePicker and attempt to select today's date, the DateSelected event is not fired therefore failing to bind to the new date. The only way to fire the DateSelected event is to select a different date on the DatePicker and then go back and select today's date.

(Since I am not testing on iOS, I cannot confirm if this is a bug on iOS)

Steps to Reproduce

  1. Create a DatePicker and bind the Date property to a null date property within a model.
  2. Create a function in the code behind file to be called when DateSelected event is fired.
  3. Use a breakpoint (or pop-up) in the code behind function.
  4. Select today's date with the DatePicker.
  5. Watch as the function in the code behind isn't called.

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

My terrible and unacceptable workaround is setting model properties in the code behind.

Relevant log output

No response

EmberLynn avatar Aug 03 '22 20:08 EmberLynn

I'm having the same issue (using Windows platform)... it seems like the Date binding is not being observed by the control. I have tried OneWay and TwoWay to no avail. The only workaround I could find was to attach a EventToCommandBehavior to the DateSelected event.

GuildOfCalamity avatar Aug 20 '22 17:08 GuildOfCalamity

Same problem using visual studio 2022 17.4.0 Preview 1.0 with MAUI. Setting the Datepickers Date to ViewModel observableProperty via Binding and changing the binding source value does not update to the Datepicker. Datepicker only shows todays date and Binding do not change it.

ideas2appsaustralia avatar Aug 23 '22 10:08 ideas2appsaustralia

@samhouts Could you reconsider this item? Having the Date binding not work on Android is the mainline, most basic scenario for this control, which leaves it broken out of the box. It seems like it shouldn't be in the backlog.

peruchali avatar Jun 28 '24 08:06 peruchali