ExpandableObjectConverter -> TypeConverter

Grids for WPF Forum

Posted 16 years ago by Jason
Version: 4.5.0470
Avatar
Hi,

It looks like the property grid has no support for properties marked with TypeConverterAttribute subtype of ExpandableObjectConverter.

see these links for info:

(http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=ExpandableObjectConverter)

(http://msdn.microsoft.com/en-us/library/system.componentmodel.expandableobjectconverter.aspx)

Is is true that this is not supported currently and will this be supported in a future release? When will that future release be?

For example I have objects with properties that are collections of other objects. I want to be able to expand these other objects in the property grid. This works fine with the WinForms grid but not with yours. In your grid it looks like somewhere along the line ToString() on the collection property is being called, rather than looking at the type converter and taking the appropriate action.


Thanks,

Jason

Comments (10)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

ExpandableObjectConverter is supported and is demonstrated by the Lazy Loading QuickStart, but there is one issue. Currently, the TypeConverter is not used to convert a property to a string, but is used to convert from a string.

We have this issue on the TODO list and will try to get to it soon, although it may not make the upcoming build.

If you are encountering another issue, then please let us know.


Actipro Software Support

Posted 15 years ago by Jason
Avatar
I just want to make sure this is just an indirect bug as a result of the TypeConverter not being used to convert to a string and you understand fully what I mean.

My issue is only indirectly related to converting the property to a string, so it might be a different issue. I have a TypeConverter that is actually a subclass of ExpandableObjectConverter. I override GetProperties() to return the properties that I want displayed.

In the source code for the LazyLoading QuickStart, you are not using TypeConverter anywhere. What you appear to be doing is simply reflecting on the object.

I am doing something quite different, which works perfectly fine with the WinForms .Net built in property grid.

Instead of setting the propertygrid SelectedObjects property to a real object, I set it to an object that implements ICustomTypeDescriptor. You appear to correctly look for this interface and use the values passed in.

When iterating over the properties (ICustomTypeDescriptor.GetProperties()), each PropertyDescriptor has a Converter property (of type TypeConverter). When debugging, I can see that this property is never even looked at (although other properties, like Name, are). This coincides with what you said about the TypeConverter not being used to convert to a string.

However, I need more than the ConvertTo method to be called. If you look at this TypeConverter there are methods GetPropertiesSupported() and GetProperties(), which should be used to populate the properties for this object. This is what the .Net WinForms property grid does.

So, is this something that is supported (but buggy as you said), or is this scenario not yet supported at all?

Thanks,

Jason

[Modified at 10/01/2008 03:29 PM]
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

Could you please put together a small sample project that shows the issue you seeing and send it over? Once we get that we can debug it and figure out what's going on.

Thanks


Actipro Software Support

Posted 15 years ago by Jason
Avatar
I emailed you a sample of what I am talking about. This isn't actually the real implementation; merely, it demonstrates what the ExpandableObjectConverter is all about.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

There was a issue with defining the TypeConverterAttribute on the property, versus on the class (which the Lazy Loading QS does). We have fixed this issue and it will be included in the next maintenance release.


Actipro Software Support

Posted 15 years ago by Jason
Avatar
I have the current release (v4.5.0477). My type converters are now properly being called, however the context is always null. For example, if you inherit from ExpandableObjectConverter, you can override GetProperties, with this signature:

public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)

Here, "context" variable is null. Is this going to be supported in a future release (ie, be not null and have real data associated with it) or is this perhaps something I am doing wrong?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

We don't currently support ITypeDescriptorContext, but I've added this to the TODO list to include in a future release. Therefore, the context will always be null at this time.


Actipro Software Support

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

Just wanted to let you know that we have added partial support for ITypeDescriptorContext, which includes the Instance and PropertyDescriptor properties. The other members of that interface do not really apply at this time.

This will be available in the next maintenance release.


Actipro Software Support

Posted 15 years ago by Jason
Avatar
I am just getting back to this now:

I'm on 4.5.486.0 of WPF Studio, and the "context" argument is still null (even in the simple sample I sent you). Do you need me to resend that sample?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jason,

Looks like the GetProperties method was the only one not getting the context correctly. I have fixed this for the next maintenance release. I also corrected an issue with our context.Instance, in that it did not fully replicate how the WinForms PropertyGrid works.

[Modified at 03/12/2009 03:44 PM]


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.