I'm trying to write a Value converter to use to bind the Boolean IsChecked property of a WPF ToggleButton to a non Boolean value (which happens to be a double) in my model. The convert function I've written looks like this:
public object Convert(object value, Type targetType, object paramter, System.Globalization.CultureInfo culutre)
{
if (targetType != typeof(Boolean))
throw new InvalidOperationException("Target type should be Boolean");
var input = double.Parse(value.ToString());
return (input==0.0) ? false: true;
}
The problem is that when the funcion is invoked, the targetType is not what I expect - it's
"System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
Rather than System.Boolean. Is this expected? I've written other converters with no hassle in the past.