IntegerUpDown: Text property and actual text gets unsynchronized


Problem:The text that is displayed in my IntegerUpDown's textbox does not match the Text property of the IntegerUpDown (the Text property of IntegerUpDown.Textbox matches IntegerUpDown.Text) when using the Maximum property.Repro:1. Create an IntegerUpDown on the page with Maximum set to 1023.2. Run the page, and type in 1024. It changes the value to 1023 automatically.3. Type 4. The text displayed is 10234, but the Text and Value property is 1023.My solution:Modify UpDownBase's SyncTextAndValueProperties method:protected void SyncTextAndValueProperties(DependencyProperty p, string text){ ... Text = ConvertValueToText(); //my code here if(TextBox != null && TextBox.Text.Equals(Text)) { TextBox.InvalidateProperty(TextBox.TextProperty); } //end of my code#if VS2008 ...}
Closed Jun 15, 2013 at 2:29 AM by emartin


BoucherS wrote Oct 22, 2012 at 4:21 PM

Will be fixed in v1.8

wrote Oct 22, 2012 at 4:24 PM

wrote Oct 24, 2012 at 3:25 PM

wrote Nov 1, 2012 at 12:02 AM

jenik15 wrote Nov 1, 2012 at 12:05 AM

Thanks for code. I noticed also that if i will enter 'abc' 'text' property will be empty!!!

So i cannot actually check user input!

wrote Nov 7, 2012 at 6:57 PM

wrote Nov 7, 2012 at 6:58 PM

wrote Nov 7, 2012 at 7:21 PM

jenik15 wrote Nov 8, 2012 at 9:15 PM

I can reproduse this in v1.8
For example type
and on lost focus text and value will be set to other value.
How to check than real input?

jenik15 wrote Nov 8, 2012 at 9:29 PM

Sorry i check this again in v1.8 and its looks like replaced automatically. But still on lost focus i got not correct text.

wrote Nov 13, 2012 at 2:15 PM

emartin wrote Nov 16, 2012 at 8:26 PM

jenik15, Yes, the Text property will have been reversed to the last valid integer value before the LostFocus event have been raised. This control has been created to input an integer value, and any input that does not resolved as an interger is rejected and revert to the last valid input.

Could you provide me with more detail on your need to validate an "invalid" text input ?
In the meantime, overriding the "ConvertTextToValue()" method will give you access to this invalid text.

emartin wrote Nov 21, 2012 at 2:58 PM

Hopefully fixed in v1.9

wrote Feb 5, 2013 at 3:39 PM

wrote Feb 22, 2013 at 2:57 AM

wrote May 16, 2013 at 1:39 PM

wrote May 16, 2013 at 1:39 PM

wrote Jun 14, 2013 at 8:36 AM

wrote Jun 15, 2013 at 2:29 AM