From 7e170e28b3d44cbad3eb8a1efc98f1cdc24103a8 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Mon, 17 May 2021 10:02:13 -0400 Subject: [PATCH] fix(calendardatepicker): fixed date picking were not working. --- .../CalendarView/CalendarDatePicker_Features.xaml | 1 - .../CalendarView/calendardatepicker_partial.cs | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CalendarView/CalendarDatePicker_Features.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CalendarView/CalendarDatePicker_Features.xaml index dfb7f89e5f0f..f2c35f2164e1 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CalendarView/CalendarDatePicker_Features.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CalendarView/CalendarDatePicker_Features.xaml @@ -92,7 +92,6 @@ CalendarIdentifier="{Binding SelectedItem.Content, ElementName=cid}" Header="IsGroupLabelVisible=False" PlaceholderText="--PLACEHOLDER--" - IsCalendarOpen="True" IsGroupLabelVisible="False" DayOfWeekFormat="{Binding SelectedItem.Content, ElementName=dowf}" FirstDayOfWeek="{Binding SelectedItem.Content, ElementName=dow}" diff --git a/src/Uno.UI/Microsoft/UI/Xaml/Controls/CalendarView/calendardatepicker_partial.cs b/src/Uno.UI/Microsoft/UI/Xaml/Controls/CalendarView/calendardatepicker_partial.cs index a1909be894d3..b99a632dd4a5 100644 --- a/src/Uno.UI/Microsoft/UI/Xaml/Controls/CalendarView/calendardatepicker_partial.cs +++ b/src/Uno.UI/Microsoft/UI/Xaml/Controls/CalendarView/calendardatepicker_partial.cs @@ -102,12 +102,12 @@ internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs arg } else if (args.Property == CalendarDatePicker.DateProperty) { - DateTime spNewDateReference; - DateTime spOldDateReference; + DateTime? spNewDateReference; + DateTime? spOldDateReference; //CValueBoxer.UnboxValue(args.OldValue, spOldDateReference); //CValueBoxer.UnboxValue(args.NewValue, spNewDateReference); - spOldDateReference = (DateTime)args.OldValue; - spNewDateReference = (DateTime)args.NewValue; + spOldDateReference = (DateTime?)args.OldValue; + spNewDateReference = (DateTime?)args.NewValue; OnDateChanged(spOldDateReference, spNewDateReference); } else if (args.Property == FrameworkElement.LanguageProperty || @@ -306,7 +306,7 @@ private void OnSelectedDatesChanged( if (!m_isSelectedDatesChangingInternally) { CalendarViewSelectionMode mode = CalendarViewSelectionMode.None; - m_tpCalendarView.SelectionMode = mode; + mode = m_tpCalendarView.SelectionMode; // We only care about single selection mode. // In case the calendarview's selection mode is set to multiple by developer, @@ -361,7 +361,7 @@ private void OnDateChanged( minDate = MinDate; maxDate = MaxDate; //coercedDate.UniversalTime = Math.Min(maxDate.UniversalTime, Math.Max(minDate.UniversalTime, date.UniversalTime)); - coercedDate = new DateTime(Math.Min(maxDate.UtcTicks, Math.Min(minDate.UtcTicks, date.UtcTicks)), TimeSpan.Zero); + coercedDate = new DateTime(Math.Min(maxDate.UtcTicks, Math.Max(minDate.UtcTicks, date.UtcTicks)), TimeSpan.Zero); // if Date is not in the range of min/max date, we'll coerce it and trigger DateChanged again. //if (coercedDate.UniversalTime != date.UniversalTime)