microsoft / XamlBehaviors

This is the official home for UWP XAML Behaviors on GitHub.
MIT License
701 stars 112 forks source link

TypeConverterHelper.Convert cannot convert double value in the language of which is comma (,) decimal point. #67

Open mntone opened 8 years ago

mntone commented 8 years ago

TypeConverterHelper.Convert cannot convert double value in the language of which is comma (,) decimal point. (e.g. Deutsch) Its methods is dependent on OS culture (see below). Is this behavior bug, or by design?

I also confirmed Windows Phone 8.1 version Behavior SDK.

// Value types in the "System" namespace must be special cased due to a bug in the xaml compiler
if (string.Equals(scope, "System", StringComparison.Ordinal))
{
  ...
  else if (string.Equals(destinationTypeFullName, typeof(double).FullName, StringComparison.Ordinal))
  {
    return double.Parse(value, CultureInfo.CurrentCulture); // ← HERE!
  }
}

https://github.com/Microsoft/XamlBehaviors/blob/858fc2b954635e3280f1eeb634773320ecc5cc58/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Core/TypeConverterHelper.cs#L51

pedrolamas commented 8 years ago

Just by looking at the code, this actually seems fine as the value arriving to the TypeConverterHelper.Convert method it getting a ToString() call done to it (which is the same as using ToString(CultureInfo.CurrentCulture)).