entry round the value

hi,
I try to use the sfNumericTextBox and I have a problem. 
My xaml is like this:

<numericEntry:SfNumericTextBox Value="1,235487" ValueChangeMode="OnLostFocus" MaximumNumberDecimalDigits="8"/>

and the entry display 1.24000000
I would like my entry display the exact value without round and without adding '0'

Is it a way to do that?

Regards
Sebastien Seyres

3 Replies 1 reply marked as answer

ET Eswaran Thirugnanasambandam Syncfusion Team May 10, 2021 08:09 AM UTC

Hi Sébastien Seyres, 
 
Thanks for contacting Syncfusion support.  
 
We have checked the reported query “SfNumerinTextBox shows round value instead of actual value”. The SfNumerinTextBox Value gets rounded based on its MaximumDecimalDigit property. The default value of Maximum decimal digit is 2, so when updating the Value property first in the control, it gets formatted with default MaximumDecimalDigit value. After updating MaximumDecimalDigit property, again it will get re-format with its new value.   
 
Your requirement can be achieved by updating the Maximum decimal digit value first and update the value property at last as per the below code snippet. 
 
Code snippet:  
 
<StackLayout Margin="10">  
 
            <textbox:SfNumericTextBox MaximumNumberDecimalDigits="8" Value="1,235487" ValueChangeMode="OnLostFocus" />  
 
        </StackLayout> 
 
 Regards, 
Eswaran 


Marked as answer

SS Sébastien Seyres May 10, 2021 09:32 AM UTC

Thanks it's work.
I have an other problem. If the init value is an empty string, there is an exception and a crash of my appli when focus out the sfnumericEntry

<numericEntry:SfNumericTextBox MaximumNumberDecimalDigits="8"  Value="{Binding NewMesure,Mode=TwoWay}"
                                                               ValueChangeMode="OnLostFocus"  />

If NewMesure is an empty string-> app crash with an exception 'Input string was not in a correct format.'



ET Eswaran Thirugnanasambandam Syncfusion Team May 10, 2021 01:09 PM UTC

Hi Sébastien Seyres, 
 
Thanks for your update. 
 
If you like to show empty value, you can achieve this by setting AllowNull as true in SfNumericTextBox and bind nullable double property for Value as per the below code snippet. 
 
Code snippet 
 
  <textbox:SfNumericTextBox MaximumNumberDecimalDigits="8"  
                                      AllowNull="True" 
                                      Value="{Binding NewMesure,Mode=TwoWay}" 
                                      ValueChangeMode="OnLostFocus"  /> 
 
 
public class ViewModel 
    { 
        private double? newMesure = null; 
 
        public double? NewMesure 
        { 
            get { return newMesure; } 
            set { newMesure = value; } 
        } 
 
    } 
 
Load time this will show empty textbox. Once you typed the text, it will get format based on MaximumDecimalDigits. 
 
Note : SfNumericTextBox is an numeric entry. So, we have to bind numeric type property alone for this control. 
 
Please refer below link for more details about AllowNull property. 
 
 
Let us know if you have any other queries 
 
Regards, 
Eswaran 


Loader.
Up arrow icon