Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimePicker changes date to 1/1/0001 when selecting time first #3746

Closed
didster opened this issue Feb 18, 2020 · 8 comments · Fixed by #3775
Closed

DateTimePicker changes date to 1/1/0001 when selecting time first #3746

didster opened this issue Feb 18, 2020 · 8 comments · Fixed by #3775
Labels
Milestone

Comments

@didster
Copy link

didster commented Feb 18, 2020

Firstly great work!

Using DateTimePicker in 2.0.0-alpha0660

Selecting a time from the dropdown before selecting the date changes the date to 01/01/0001.

DateTimePicker is bound to a nullable date time. Same occurs when DateTimePicker is not bound to anything at all actually.

It works fine in 1.6.5 where selecting the time first still results in the textbox saying "select a date"

I must target .net core, so sadly can't use 1.6.5

Here is an example of both

Doesnt work using 2.0.0 alpha
Works using 1.6.5

@punker76 punker76 added the Bug label Feb 18, 2020
@didster
Copy link
Author

didster commented Feb 27, 2020

Unsure if this is related but also when ever I use DateTimePicker in alpha, I get these three binding errors:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'Name' (type 'String')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'LabeledBy' (type 'UIElement')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DatePicker', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'DatePickerTextBox' (Name='PART_TextBox'); target property is 'HelpText' (type 'String')

@punker76
Copy link
Member

@didster Are you targeting .Net Framework 4.8? If yes, then it's a problem there.

@didster
Copy link
Author

didster commented Feb 27, 2020

@punker76 No, I'm targeting .NET Core 3.1. I have also tried Core 3.0, same result. The non-alpha project using 1.6.5 targets Framework 4.7.2 and works fine. I have not tried 4.8.

I have also just tried using Framework 4.7.2 and the alpha version just out of interest. No binding errors shown, but the original reported problem of the date showing 1/1/0001 when you change the time is still exhibited so I guess they are not related anyway.

@didster
Copy link
Author

didster commented Feb 29, 2020

A further point for this is I hadn't noticed is that it does the same in reverse when you select the date first - the time time resets to 00:00.

@dj060004
Copy link

+1 for this fix as the control is pretty much unusable currently. Is their an ETA? Many thanks.

@punker76 punker76 added this to the 2.0.0 milestone Apr 17, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 19, 2020
…icker

- if the Time is selected before a Date is selected use DateTime.Today instead of DateTime.Min
- If a new Value is selected from the Calendar we use the already Selected time.
- Implemented a new private `bool` to disable changing the time.
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 19, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 19, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 21, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 21, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 21, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
…icker

- if the Time is selected before a Date is selected use DateTime.Today instead of DateTime.Min
- If a new Value is selected from the Calendar we use the already Selected time.
- Implemented a new private `bool` to disable changing the time.
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 26, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
…icker

- if the Time is selected before a Date is selected use DateTime.Today instead of DateTime.Min
- If a new Value is selected from the Calendar we use the already Selected time.
- Implemented a new private `bool` to disable changing the time.
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 28, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 29, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 29, 2020
…icker

- if the Time is selected before a Date is selected use DateTime.Today instead of DateTime.Min
- If a new Value is selected from the Calendar we use the already Selected time.
- Implemented a new private `bool` to disable changing the time.
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 29, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue Apr 29, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
…se RoutedPropertyChangedEventHandler and RoutedPropertyChangedEventArgs
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 3, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
…icker

- if the Time is selected before a Date is selected use DateTime.Today instead of DateTime.Min
- If a new Value is selected from the Calendar we use the already Selected time.
- Implemented a new private `bool` to disable changing the time.
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
…se RoutedPropertyChangedEventHandler and RoutedPropertyChangedEventArgs
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 4, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 6, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 6, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 6, 2020
punker76 added a commit to timunie/MahApps.Metro that referenced this issue May 6, 2020
punker76 added a commit that referenced this issue May 6, 2020
(GH-3746) Fix Date and Time selection and other improvements for DateTimePicker
@punker76
Copy link
Member

@didster The BindingExpression error has now been fixed, and it will be released in the next version of MahApps.Metro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants