W
Wonko the Sane
Hello All,
I am having an issue with decimal separators and localization. Assume that
I have set Regional Settings to, say, German, where the decimal separator is
a comma.
When I bind directly to a Double value, the value shows up correctly.
However, if I go through a data converter, the value is always coming back
with a decimal point (period).
See abbreviated code example below.
Thanks,
WtS
<!-- In XAML - DataContext set to a DataTable -->
<TextBlock Text={Binding Converter={StaticResource SomeConverter},
ConverterParameter=SomeKey} />
// IValueConverter class example - usually has more error checking, etc.
class SomeConverter : IValueConverter
{
public object Convert(...)
{
DataTable dt = (DataTable) value;
String key = parameter.ToString();
DataRow [] rows = dt.Select("Data = '" + key + "'");
return Double.Parse(rows[0]["CurrentValue"].ToString());
}
}
I am having an issue with decimal separators and localization. Assume that
I have set Regional Settings to, say, German, where the decimal separator is
a comma.
When I bind directly to a Double value, the value shows up correctly.
However, if I go through a data converter, the value is always coming back
with a decimal point (period).
See abbreviated code example below.
Thanks,
WtS
<!-- In XAML - DataContext set to a DataTable -->
<TextBlock Text={Binding Converter={StaticResource SomeConverter},
ConverterParameter=SomeKey} />
// IValueConverter class example - usually has more error checking, etc.
class SomeConverter : IValueConverter
{
public object Convert(...)
{
DataTable dt = (DataTable) value;
String key = parameter.ToString();
DataRow [] rows = dt.Select("Data = '" + key + "'");
return Double.Parse(rows[0]["CurrentValue"].ToString());
}
}