Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1280
XamNumericEditor format - UI Culture
posted

Hello everybody,

in my MVVM application I am using XamNumericEditor to get/set user's input about numeric properties.

My application is fully localized: when the user select from a XamMenu a different language, all texts are localized to selected locale/culture.

i would like to achieve same goal with XamNumericEditor.

I have a field properties that with en-US is 1,500.35 and would like it to be 1.500,35 if I switch to it-IT.

Moreover: it is not enough for it to be displayed according to current culture, but I'd like the runtime editing to be culture-specific: if I input "3500", when I input the second "0" the comma (NumberGroupSeparator) automatically appears.

Is there a way to do this?

Alternatively, would you help me suggesting a way to do this with XamTexEditor (I would need an additional numbering validation) if with XamNumericEditor it is too complex/unfeasible?

Thanks in advance

Valentina

Parents
  • 1530
    Verified Answer
    posted

    Hi Valentina,

    You can try setting the xamNumericeditor's FormatProvider to the new culture and change the NumberDecimalSeparator and NumberGroupSeparator according to your needs like this:

    CultureInfo culture = new CultureInfo("it-IT");
                culture.NumberFormat.NumberDecimalSeparator = ",";
                culture.NumberFormat.NumberGroupSeparator = ".";
                editor.FormatProvider = culture;

    I've created a sample which demonstrates how to achieve this and which you can use as a starting point.

    If you require any further assistance on the matter, please let me know.

    Sincerely,
    Teodor Tenev
    Software Developer

    NumericEditorEditModeFormat.zip
Reply Children