wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

DateTimePicker editing broken

Open xceedsoftware opened this issue 8 years ago • 5 comments

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.

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware

BoucherS[CodePlex]
Hi,

This is already fixed. The fix will be included in v3.1. Thanks.

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware

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.

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware

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.

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware

PeterJarrett[CodePlex]
I should also add that this is using Databinding to a TimeSpan property in our viewmodel, and the Format=ShortTime - we also

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware

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.

xceedsoftware avatar Jul 13 '17 11:07 xceedsoftware