I have to convrt a double to other using a converter and a parameter:
This is my XAML stub:
Converter={StaticResource ToOtherDoubleConverter}, ConverterParameter=-1/2
this is the converter:
[ValueConversion(typeof(double), typeof(double))]
public class DoubleToOtherDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
return (double)value * double.Parse(parameter.ToString());
}
Now, this is useless to say that this is culture dependent, etc..
Is there a way to “hardcode” a double to be recognized as double?
Because the above variant could be written in different ways, by eg.:
ConverterParameter=-1/2
ConverterParameter=-0.5
ConverterParameter=-0,5
etc.
or also
double.Parse(parameter.ToString());
(double)parameter;
etc…
One more question:
How can I specify 1/3 in the floating format? something like
ConverterParameter=0.333333333333333333333333333333333333333333333333333333
try this