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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfnumericupdown "recursive" binding

Thread ID:

Created:

Updated:

Platform:

Replies:

144956 May 30,2019 08:39 AM UTC Jun 2,2019 06:28 PM UTC Xamarin.Forms 2
loading
Tags: SfNumericUpDown
Ilya
Asked On May 30, 2019 08:39 AM UTC

hi,

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.

sincerely
ish

Ilya
Replied On 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 

ish

Iyyappan Mani [Syncfusion]
Replied On 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.  

Regards, 
Iyyappan M.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon