RadNumericUpDown and Globalisation/Localisation

1 Answer 57 Views
Localization NumericUpDown
Giuseppe
Top achievements
Rank 1
Giuseppe asked on 15 Sep 2023, 11:36 AM

Hello,

I'm using several RadNumericUpDown controls and when the language/region is set to English, as expected they show numbers with dots as decimal separators, which is fine. But when I set any European language/region they still show dots rather than commas. How can I fix this issue?

My code is like the snippet below:

                                       <telerik:RadNumericUpDown Value="{Binding ScaleMin}" HorizontalAlignment="Stretch" Width="120" Margin="5"
                                                              VerticalAlignment="Center" SmallChange="0.1" ValueFormat="Numeric" IsEnabled="{Binding IsAvailable}">
                                        <telerik:RadNumericUpDown.NumberFormatInfo>
                                            <global:NumberFormatInfo NumberGroupSeparator="" NumberDecimalDigits="1"/>
                                        </telerik:RadNumericUpDown.NumberFormatInfo>
                                        <telerik:RadNumericUpDown.Resources>
                                            <Style TargetType="{x:Type TextBox}">
                                                <Setter Property="MaxLength" Value="8"/>
                                            </Style>
                                        </telerik:RadNumericUpDown.Resources>
                                    </telerik:RadNumericUpDown>

Thanks,

G.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 20 Sep 2023, 11:10 AM

Hello Giuseppe,

You can set the NumberDecimalSeparator property of the NumberFormatInfo instance of RadNumericUpDown when changing the culture of the application. After that, call the OnApplyTemplate method of the RadNumericUpDown instance.

The following code snippet shows this suggestion's implementation:

if (Thread.CurrentThread.CurrentUICulture.Name == "de-DE")
{
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");

    this.numericUpDown.NumberFormatInfo.NumberDecimalSeparator = ".";
}
else
{
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");

    this.numericUpDown.NumberFormatInfo.NumberDecimalSeparator = ",";
}

this.numericUpDown.OnApplyTemplate();

The produced result is as follows:

If you have more than one RadNumericUpDown instance, the above suggestion could be executed via an attached property. More information on them can be found in the following article:

Attached Behavior/Properties - Telerik UI for WPF

I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Giuseppe
Top achievements
Rank 1
commented on 02 Oct 2023, 03:27 PM

Thank you for the reply, Stenly.

 

G.

Tags
Localization NumericUpDown
Asked by
Giuseppe
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or