Browse Source

Fix datepicker not refreshing format when date format changes (#18599)

* fix DatePicker not refresh when  MonthFormat or YearFormat changed

* use SetSelectedDateText instead
release/11.3.0-beta2
小松果 10 months ago
committed by Julien Lebosquain
parent
commit
b2a79a8923
  1. 4
      src/Avalonia.Controls/DateTimePickers/DatePicker.cs
  2. 4
      src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs

4
src/Avalonia.Controls/DateTimePickers/DatePicker.cs

@ -293,6 +293,10 @@ namespace Avalonia.Controls
var (oldValue, newValue) = change.GetOldAndNewValue<DateTimeOffset?>();
OnSelectedDateChanged(this, new DatePickerSelectedValueChangedEventArgs(oldValue, newValue));
}
else if (change.Property == MonthFormatProperty || change.Property == YearFormatProperty || change.Property == DayFormatProperty)
{
SetSelectedDateText();
}
}
private void OnDismissPicker(object? sender, EventArgs e)

4
src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs

@ -312,6 +312,10 @@ namespace Avalonia.Controls
{
OnDateRangeChanged(this, change);
}
else if (change.Property == MonthFormatProperty || change.Property == YearFormatProperty || change.Property == DayFormatProperty)
{
InitPicker();
}
}
protected override void OnKeyDown(KeyEventArgs e)

Loading…
Cancel
Save