0
votes

I Need your help. I've started a Web-App using WinJS and WinJS.Binding. Everything works fine except when displaying decimals. Decimals are always be shown in the US Format (e.g. 1,000.23) but I need those displayed in the Format for the current region (e.g. in Germany it should Display 1.000,23).

So I tried to use a WinJS.Binding.converter but the problem is, that I already use a two way binding initializer and when I try to use the initializer and the convert it raise an error:

WinJS.Binding.ParseError: Invalid binding:'value: dataSource.aDechimalValue Binding.Mode.twoWay Converters.dec'. Expected to be ':;'. Unexpected token: semicolon, expected token: colon, at offset 67

Here the HTML how I set data-win-bind:

<input id="aDecimalInput" type="number" data-win-bind="value: dataSource.aDechimalValue Binding.Mode.twoWay Converters.dec" />

So here's my question:

How can I display decimal values - or later also Dates - in the Format of the current region?

Best regards, Mike

1

1 Answers

0
votes

Try using this in your script :

Double dblValue;
if (Double.TryParse(value1, NumberStyles.Number, CultureInfo.CurrentCulture, out dblValue)){
    document.getElementById(aDecimalInput).text = value1;
}

this will write your decimal value depending on the your country with a coma or a dot.