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

Localized Formatting for SfNumericTexbox

I am using SfNumericTextbox but cannot handle formatting. 
I've written a helper and it works for label somehow, doesn't work for numerictextbox

What I want is to put; 
- comma as decimal delimiter, 
- dot as thousand delimiter 
- (optionally) binded symbol for currency 

Sample result I want to achieve; 1.500,25 

       <inputLayout:SfTextInputLayout
               Hint="Budget"
               ContainerType="Outlined" 
                ReserveSpaceForAssistiveLabels="False">
                    <numericBox:SfNumericTextBox Value="{Binding BudgetAmount, Mode=TwoWay, Converter={StaticResource numericLabelFormatConverter}}" />
       </inputLayout:SfTextInputLayout>


        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double amount = System.Convert.ToDouble(value);
            return Math.Round(amount, 0).ToString("N0", new CultureInfo("tr-TR"));
        }

Thanks in advance for your kindly support. 

5 Replies

RA Rachel A Syncfusion Team August 26, 2019 01:48 PM UTC

Hi Murat,

 
Greetings from Syncfusion.

 
You can achieve your requirement using the Culture property in the SfNumericUpDown control. Please refer the below code snippet for reference.

 
Code Snippet:

 
XAML 
 <inputLayout:SfTextInputLayout
               Hint="Budget"
               ContainerType="Outlined" 
                ReserveSpaceForAssistiveLabels="False">
                    <numericBox:SfNumericTextBox  MaximumNumberDecimalDigits="2" x:Name="numericTextBox" />
       </inputLayout:SfTextInputLayout>
 
 
 
C#: 
numericTextBox.Culture = new CultureInfo("tr-TR"); 
 
 
Screenshot:

 


 
Please let us know if you need further assistance on this.

 
Regards, 
Rachel. 
  



MU Murat August 27, 2019 05:24 AM UTC

Thank you, Rachel. It worked currently. However, is there any other way if I use ViewModel behind content page? 

Because I need to change localization regarding to currency settings of user. So I want to check and set the culture in the ViewModel.cs (not in *.xaml.cs)


RA Rachel A Syncfusion Team August 28, 2019 08:41 AM UTC

Hi Murat, 
 
We have modified the sample by declaring Culture property in the ViewModel as per your request. Please find the modified sample below. 
 
Sample: 
 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Rachel. 



MU Murat September 3, 2019 10:56 AM UTC

I really appreciate it, Rachel.  

It's definitely worked. 



RA Rachel A Syncfusion Team September 3, 2019 11:00 AM UTC

Hi Murat, 
 
Thanks for the confirmation. 
 
Please let us know if you have any other queries. 
 
Thanks, 
Rachel. 


Loader.
Live Chat Icon For mobile
Up arrow icon