3

Closed

IntegerUpDown: Text property and actual text gets unsynchronized

description

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 1:29 AM by emartin

comments

BoucherS wrote Oct 22, 2012 at 3:21 PM

Will be fixed in v1.8

jenik15 wrote Oct 31, 2012 at 11:05 PM

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

So i cannot actually check user input!

jenik15 wrote Nov 8, 2012 at 8:15 PM

I can reproduse this in v1.8
For example type
'abc'
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 8: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.

emartin wrote Nov 16, 2012 at 7: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 1:58 PM

Hopefully fixed in v1.9