We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

sfnumericupdown "recursive" binding


lets bind sfnumericupdown and  add ivalueconverter. then,  place breakpoints on Convert and ConvertBack methods and debug. 
we see, that on init, firstly will be called Convert and then immidiately convertback.

in some situation it brings the recursive or event infinite side effect. 

i am writing metric to imperial weights converter..for simplicity internal storage is in gramms, 4 digits after decimal point.
but when i output data to user, i show only 1 digit, after decimal point. 

lets say we have 40 kg
1. convert called with object value 40, it is converted to 88.185 lbs and output to control as 88.2 lbs
2. immidiately convertback called with value 88.2 which converts back and, surprise, it is 40.0068
3. now you update source with this new value, which effectively overcome simple check if (weight == value) return;
4. source updates with new value and send new notifypropertychanged, 
5. which effectively brings us to item 1 of this sequence with the value 40.0068 and this will continue until it reaches the value which converts without rounding ;)

this sample is not to discuss how to write metric to imperial conversion. i just wonder , what is the reason to update
source immidiately after reading it ?

i think that this is wrong behaviour . you should not update source when control value just changed from source.


2 Replies

IL Ilya May 30, 2019 09:33 AM UTC

also, the excess call to convertback is when user change value in the control 
so it works
1. control calls convertback, put new value in binded property
2. property fires onproperty change
3. control calls convert and the again convertback

1 and 3 call with the same value 


IM Iyyappan Mani Syncfusion Team June 2, 2019 06:28 PM UTC

Hi Ilya, 

Thank you for your interest in Syncfusion products. 
We have analyzed your requirement and prepared the sample with given information in the last previous update.  

Could you please provide more information about the process that you are performing in the converter, or modify the sample we provided above, and it will help to provide a better solution.  

Iyyappan M.

Live Chat Icon For mobile
Up arrow icon