When we use static double values in XAML, how can we specify in which format they are provided?
Example:
<Rectangle>
<Rectangle.Opacity>
<Binding Path="IsDimmed" Converter="{StaticResource boolToDoubleConverter}" ConverterParameter="0.8"/>
</Rectangle.Opacity>
</Rectangle>
with the converter method
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return double.Parse((string)parameter, culture);
}
The problem is that on a machine, where decimals are separated by ,
, the conversion method fails or returns a wrong value, respectively.
I do not want to set the InvariantCulture in the Parse()
method, because the converter might in some place be used to parse user input, which is why the culture
parameter should still be applied.
If I specify the value as a resource with <sys:Double x:Key="dimValue">0.8</sys:Double>
, the converter parameter becomes a double type but before being parsed is cast to a string.
So I would like to specify somehow, that the value is indicated in en-GB format like ConverterParameter="0.8" ConverterParameterCulture="en-GB"/>
.
Is this possible somehow without the need to create a puffy MultiValueConverter?