I am trying to implement in the property grid, a dropdown that is populated from List<string>, or string[]. (And yes, I have seen the TypeConverter sample provided by Bertrand). I have tried three different approaches.
The first approach, similar to that used by Bertrand in his sample, does populate the dropdown but the first line is blank. I have checked the code thoroughly but cannot see the issue Any suggestions, please?
The second approach uses a class and requires, in the TypeConverter function, an override for StandardValuesCollection GetStandardValues(ITypeDescriptorContext context). I use
var myClass = context.Instance as MyClass.Options;
The third approach also uses a class and requires, in the TypeConverter function, an override for StandardValuesCollection GetStandardValues(ITypeDescriptorContext context). I use
var choices = context.PropertyDescriptor.Attributes.OfType<ListT ypeConverterAttribute>().FirstOrDefault()?.List;
(Yes, I am aware this is C#6 and wont compile in NT but I am simply showing it here for succintness. That is not the issue.)
The issue is that the ITypeDescriptorContext context is null. Does NT actually return a property grid context that is not null?
Any suggestions would be greatly appreciated. Thank you.
Comment