- camimamedov
- Posts: 6
- Joined:
Value Converter binding converter failed to convert value 'null'
I created a converter that changes width value
But in Unity I get this errors
'Dynamicbox.Converters.GridWidthConverter' binding converter failed to convert value 'null' (type 'Int32')
Binding failed: Path=GridWidth, Source=ViewModel(''), Target=Grid('gridPlayerLevelBar'), TargetProperty=FrameworkElement.Width
How can I fix this problem?
Code: Select all
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int width;
if (value == null || !int.TryParse(value.ToString(), out width)) width = 0;
double factor;
if (parameter == null || !double.TryParse(parameter.ToString(), out factor)) factor = 0;
return width * factor;
}
'Dynamicbox.Converters.GridWidthConverter' binding converter failed to convert value 'null' (type 'Int32')
Binding failed: Path=GridWidth, Source=ViewModel(''), Target=Grid('gridPlayerLevelBar'), TargetProperty=FrameworkElement.Width
How can I fix this problem?
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Value Converter binding converter failed to convert value 'null'
Try returning the value as a float, because I guess this converter was applied to the Width property of a UI element, right?
There is a known issue regarding the values returned by converters, #1376, so for now the converters need to return the type of the target property.
Code: Select all
return (float)(width * factor);
- camimamedov
- Posts: 6
- Joined:
Re: Value Converter binding converter failed to convert value 'null'
Thank you, this solved the problem
Who is online
Users browsing this forum: nevayeshirazi and 4 guests