Hi,
in the xamPropertyGrid I need to set a property value from a list of available values found in a list. I want the selectable values to end up in a combo box in the property grid.
From my initial investigation I find that a way to do this (at least in other property editors) is to use a TypeConverter attribute on my property and implement the TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) method to generate the list of available options. However, when I try this with the xamPropertyGrid I get passed a context of null in this (and related) TypeConverter methods, making it difficult to use anything but a static list of options.
Is there a way to set up a type converter with a proper context for the xamPropertyGrid, or is there an alternative way to get the combo-box experience I need ?
Regards,Leif
Hello Leif,
Thank you for your post.
Could you please send me an isolated sample application where I can reproduce your issue. This way I would be able to further investigate this for you and provide you with more detailed information on this matter.
Looking forward to hearing from you
Sincerely,
Horen
Software Developer
Infragistics
Hi
Attached is a simple sample application that shows what I mean. The object to be displayed has a single public property, Option, that can have a number of different values that are generated from a dynamic list in the data model. The property editor should display these values in a drop-down box.
The sample uses a custom TypeConverter to get the drop-down behavior 'for free'. However, the type converter methods in the sample always get passed a null value for the ITypeDescriptorContext arguments, which makes it difficult to get access to the parent object of the property when filling the list of available options. As far as I understand, a normal behavior is to e.g. pass a reference to the parent object in the context's Instance property. In the sample, code that uses such information is wrapped within a #ifdef block.
I guess that setting a property value from a list of dynamic options in a drop-down is a common usage scenario for the XamPropertyGrid, so there may be other patterns that makes this possible without using a TypeConverter. However, if the XamPropertyGrid could pass a proper context to the TypeConverter methods, this feature would be a no-brainer.
This issue was fixed in the December 2015 Service Release.