AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.45k stars 2.21k forks source link

CalendarDatePicker does not reflect changes in DisplayDateStart and DisplayDateEnd #7162

Closed timunie closed 2 years ago

timunie commented 2 years ago

Describe the bug If you initially set the properties DisplayDateStart and DisplayDateEnd the Calendar in the drop down shows correctly, but if you want to adjust the dates manually these changes are ignored.

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/timunie/Tims.Avalonia.Samples/tree/AvaloniaCalendarIssue
  2. Run the project "CalendarDatePickerIssue"
  3. Play around with the avaialable CalendarDatePickers
  4. See that the changes don't get reflected

Expected behavior Any change to the value should be reflected in the drop down

Screenshots image Upper and lower bounds should adjust the selectable / visible range in the drop down, but it doesn't

Desktop (please complete the following information):

Additional context I think this comes from these lines: https://github.com/AvaloniaUI/Avalonia/blob/885f66f769979dcbcd448d28d478909a9f69ae60/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs#L459-L483

I think there are two possible options to fix this:

  1. Use TemplateBinding which is I think the way to go, but it is a breaking change as custom styles will need to be changed also (like FluentAvalonia etc)
  2. Create the needed bindings in code behind which may be less flexible than (1) but is not a breaking change here. Which solution do you prefer? I can provide a PR if I know which way you like more.

Happy coding Tim

timunie commented 2 years ago

@danwalmsley told me that option 1 is not a breaking change, so I'll go for option 1.

@danwalmsley Thank you very much 🙏