Skip to content

Commit 2c1c692

Browse files
committed
Fix not updating the text of TimePicker and DateTimePicker after changing the culture
1 parent 3f60b85 commit 2c1c692

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/release-notes/1.6.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
+ `GroupBoxHeaderThemePadding` (default 4)
3131
+ `ExpanderHeaderThemePadding` (default 2)
3232
+ `ExpanderToggleButtonEllipseThemeSize` (default 18)
33+
- Fix not updating the text of `TimePicker` and `DateTimePicker` after changing the culture.
3334

3435
## Breaking Change
3536

@@ -75,3 +76,4 @@ More informations about the reason of this decision can be found here:
7576
- [#3025](https://github.com/MahApps/MahApps.Metro/issues/3025) ComboBox popup border thickness problem
7677
- [#3043](https://github.com/MahApps/MahApps.Metro/issues/3043) Width parse error
7778
- [#3045](https://github.com/MahApps/MahApps.Metro/issues/3045) Clicking on the "X" button added by TextBoxHelper.ClearTextButton does not clear the databinding target
79+
- [#3049](https://github.com/MahApps/MahApps.Metro/issues/3049) TimePicker fails to parse times with an AM/PM. [#3050](https://github.com/MahApps/MahApps.Metro/pull/3050) [@toddburnside](https://github.com/toddburnside)

src/MahApps.Metro/MahApps.Metro.Shared/Controls/TimePicker/TimePickerBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ protected virtual void ApplyCulture()
450450

451451
SetDefaultTimeOfDayValues();
452452
_deactivateRangeBaseEvent = false;
453+
454+
WriteValueToTextBox();
453455
}
454456

455457
protected Binding GetBinding(DependencyProperty property)
@@ -466,8 +468,7 @@ protected virtual string GetValueForTextBox()
466468

467469
protected virtual void OnTextBoxLostFocus(object sender, RoutedEventArgs e)
468470
{
469-
var text = DateTime.MinValue.ToString(SpecificCultureInfo.DateTimeFormat.ShortDatePattern) + " " +
470-
((DatePickerTextBox)sender).Text;
471+
var text = string.Intern($"{DateTime.MinValue.ToString(SpecificCultureInfo.DateTimeFormat.ShortDatePattern)} {((DatePickerTextBox)sender).Text}");
471472
DateTime dt;
472473
if (DateTime.TryParse(text, SpecificCultureInfo, DateTimeStyles.None, out dt))
473474
{

0 commit comments

Comments
 (0)