Hello,
I have a property grid with a nested property, generated by a custom class. When I modify a value I get the error in the Visual Studio output window:
System.Windows.Data Error: 23 : Cannot convert '6' from type 'String' to type 'PropertyGrid_CustomEditor.Levels' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: TypeConverter cannot convert from System.String.
at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 7 : ConvertBack cannot convert value '6' (type 'String'). BindingExpression:Path=VLevels; DataItem='Employee' (HashCode=15832433); target element is 'PropertyItem' (HashCode=38893755); target property is 'Value' (type 'Object') NotSupportedException:'System.NotSupportedException: TypeConverter cannot convert from System.String.
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.ObjectTargetConverter.ConvertBack(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertBackHelper(IValueConverter converter, Object value, Type sourceType, Object parameter, CultureInfo culture)'
I'm not sure how to go about creating a converter to convert a property value into the custom type. Would you be able to help? I've attached a sample project.
Thanks!
Alan