Skip to content

Commit 7633e09

Browse files
authored
Added cursor index retention for TimePicker. (#1675)
References #1652
1 parent 4e7b9e6 commit 7633e09

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MaterialDesignThemes.Wpf/TimePicker.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ private static void TextPropertyChangedCallback(DependencyObject dependencyObjec
5656
if (!timePicker._isManuallyMutatingText)
5757
timePicker.SetSelectedTime();
5858
if (timePicker._textBox != null)
59+
{
60+
// Save and restore the cursor position
61+
var caretIndex = timePicker._textBox.CaretIndex;
5962
timePicker._textBox.Text = dependencyPropertyChangedEventArgs.NewValue as string ?? "";
63+
timePicker._textBox.CaretIndex = caretIndex;
64+
}
6065
}
6166

6267
public string Text

0 commit comments

Comments
 (0)