protected internal virtual TypeConverter GetTypeConverter() { var tca = ClrType.GetCustomAttributes(typeof(TypeConverterAttribute), false).Cast <TypeConverterAttribute>().FirstOrDefault(); if (tca != null) { return(Activator.CreateInstance(Type.GetType(tca.ConverterTypeName)) as TypeConverter); } if (ClrType.IsEnum #if NETFX_CORE () #endif ) { return(new DelegateTypeConverter <object>((context, culture, val) => Enum.Parse(ClrType, val, false))); } if (ClrType.IsGenericType #if NETFX_CORE () #endif && ClrType.GetGenericTypeDefinition().Equals(typeof(Nullable <>))) { var nullableKind = Nullable.GetUnderlyingType(ClrType); var nullableType = ClrType; var baseTypeConverter = XamlType.GetXamlType(nullableKind).TypeConverter; return(new DelegateTypeConverter <object>((context, culture, val) => { var result = baseTypeConverter.ConvertFrom(context, culture, val); return Activator.CreateInstance(nullableType, result); })); } return(null); }