DateTimePicker editing broken
luldek[CodePlex]
I have datetimepicker with such formatstring:
dd.MM.yyyy HH:mm:ss
if i place click with mouse on minutes, both minute digits get selected. If I then press a digit, datetimepicker selects the newly pressed digit AND ALSO THE SEMICOLON!
next press of digit completely corrupts the text.
using 2.9. community.
BoucherS[CodePlex]
Hi,
This is already fixed. The fix will be included in v3.1. Thanks.
luldek[CodePlex]
I solved my problem subclassing and overriding:
class DateTimePicker: Xceed.Wpf.Toolkit.DateTimePicker
{
protected override void PerformMouseSelection()
{
base.PerformMouseSelection();
// handle seconds input
if (TextBox.SelectionStart == TextBox.Text.Length - 1 TextBox.SelectionLength == 1)
{
var prop = GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Single(f = f.Name == _fireSelectionChangedEvent);
prop.SetValue(this, false);
TextBox.Select(TextBox.Text.Length, 0);
prop.SetValue(this, true);
return;
}
// handle previous inputs
var firstnondigit = TextBox.SelectedText.IndexOfAny(new char[] { ' ', ':', '.' });
if (firstnondigit = 0)
{
var prop = GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Single(f = f.Name == _fireSelectionChangedEvent);
prop.SetValue(this, false);
TextBox.Select(TextBox.SelectionStart + firstnondigit, 0);
prop.SetValue(this, true);
}
}
}
far from optimal, works perhaps only with my particular datetime format, but for me usable enough.
PeterJarrett[CodePlex]
I've just checked this further, and if we leave the Language property as en-US this doesn't happen, but if we run it under en-GB it does happen.
During the window_Load event we do: Me.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name)
to set the language to the current locale.
PeterJarrett[CodePlex]
I should also add that this is using Databinding to a TimeSpan property in our viewmodel, and the Format=ShortTime - we also
PeterJarrett[CodePlex]
I'm having exactly the same issue, also seems to affect the TimePicker control as well.
We are running in the UK Locale if that helps track this one down.