Skip to content

Commit

Permalink
fix(datepicker): Default date were not set when the control were crea…
Browse files Browse the repository at this point in the history
…ted.

This was due to a wrong refactoring during the conversion of DatePicker from WinUI code.

This commit fixes #5510
  • Loading branch information
carldebilly committed Apr 29, 2021
1 parent 0971d5f commit daf4812
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/Uno.UI/UI/Xaml/Controls/DatePicker/DatePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ protected override void OnApplyTemplate()
m_epYearSelectionChangedHandler.Disposable = null;
}

if (m_tpFlyoutButton != null && !false)
if (m_tpFlyoutButton != null)
{
m_epFlyoutButtonClickHandler.Disposable = null;
}
Expand Down Expand Up @@ -494,12 +494,9 @@ protected override void OnApplyTemplate()

if (m_tpFlyoutButton != null)
{
if (!false)
{
m_tpFlyoutButton.Click += OnFlyoutButtonClick;
m_epFlyoutButtonClickHandler.Disposable =
Disposable.Create(() => m_tpFlyoutButton.Click -= OnFlyoutButtonClick);
}
m_tpFlyoutButton.Click += OnFlyoutButtonClick;
m_epFlyoutButtonClickHandler.Disposable =
Disposable.Create(() => m_tpFlyoutButton.Click -= OnFlyoutButtonClick);
RefreshFlyoutButtonAutomationName();
}

Expand Down Expand Up @@ -882,26 +879,23 @@ void OnGetDatePickerSelectionAsyncCompleted(
Task<DateTimeOffset?> getOperation,
AsyncStatus status)
{
if (!false)
{
// CheckThread();
// CheckThread();

m_tpAsyncSelectionInfo = null;
m_tpAsyncSelectionInfo = null;

if (status == AsyncStatus.Completed)
{
DateTimeOffset? selectedDate;
selectedDate = getOperation.Result;
if (status == AsyncStatus.Completed)
{
DateTimeOffset? selectedDate;
selectedDate = getOperation.Result;

// A null IReference object is returned when the user cancels out of the
//
if (selectedDate != null)
{
// We set SelectedDate instead of Date in order to ensure that the value
// propagates to both SelectedDate and Date.
// See the comment at the top of OnPropertyChanged2 for details.
SelectedDate = selectedDate;
}
// A null IReference object is returned when the user cancels out of the
//
if (selectedDate != null)
{
// We set SelectedDate instead of Date in order to ensure that the value
// propagates to both SelectedDate and Date.
// See the comment at the top of OnPropertyChanged2 for details.
SelectedDate = selectedDate;
}
}
}
Expand Down Expand Up @@ -1060,7 +1054,7 @@ private bool GetDefaultValue2(
}
else if (pDP == DatePicker.DateProperty)
{
if (m_defaultDate.Value.ToUniversalTime() == NullDateSentinelValue && false)
if (m_defaultDate.Value.ToUniversalTime() == NullDateSentinelValue)
{
GetTodaysDate(out m_defaultDate);
}
Expand Down Expand Up @@ -1608,7 +1602,7 @@ void UpdateFlyoutButtonContent()
// For the Threshold template we set the Day, Month and Year strings on separate TextBlocks:
if (m_tpYearTextBlock != null)
{
if (selectedDate != null || false)
if (selectedDate != null)
{
GetYearFormatter(YearFormat, strCalendarIdentifier, out spYearFormatter);
strYear = spYearFormatter.Format(date.Value);
Expand All @@ -1622,7 +1616,7 @@ void UpdateFlyoutButtonContent()
}
if (m_tpMonthTextBlock != null)
{
if (selectedDate != null || false)
if (selectedDate != null)
{
GetMonthFormatter(MonthFormat, strCalendarIdentifier, out spMonthFormatter);
strMonth = spMonthFormatter.Format(date.Value);
Expand All @@ -1636,7 +1630,7 @@ void UpdateFlyoutButtonContent()
}
if (m_tpDayTextBlock != null)
{
if (selectedDate != null || false)
if (selectedDate != null)
{
strDayFormat = DayFormat;
GetDayFormatter(strDayFormat, strCalendarIdentifier, out spDayFormatter);
Expand Down

0 comments on commit daf4812

Please sign in to comment.