This project has moved. For the latest updates, please go here.

PropertyGrid: How do I add property classes to sub property collection (explanation inside)

Jul 23, 2015 at 9:53 PM
Lets say I have an object Farm.
Farm has a collection property defined as follows:
ObservableCollection<iCrop> Crops;

Crops has classes that inherit iFruit or iVegetable etc.
IFruit inherits from iCrop.

These classes will be apple, banana, carrot, squash etc

I have a static collection that lists all the available classes - loaded at runtime.
Let's call this ObservableCollection<iCrop> CropsBase;

When I assign Farm to propertygrid and then lcik on Crops to open collection dialog, how do I assign CropsBase to the list of types to add?
Jul 27, 2015 at 4:25 PM

You should add the NewItemTypes attribute over the "Crops" property. Something like
[NewItemTypes( typeof( Banana ), typeof( Apple ), typeof( Carrot ) )]
public ObservableCollection<iCrop> Crops
But there is a bug in the current version of the Toolkit. The "NewItemTypes atribute" is not working since v2.3.

Issue has been created