Dynamic Element Properties?

Jul 29 at 8:27 PM
Jezz,

First off, great job with nupattern. It has come a long way since the old PLATU days - you even got it to the point that I'm reading the guidance ;)

Anyway, I have a chance to use nupattern to build a proof of concept toolkit here. Things are going well so far, but I've found an area where I'm spinning so I thought I'd ask for some help.

I put together a few screenshots that I hope will give you some context:

Author Experience
Image

User Experience
Image

User Experience Property Window
Image

I'm using a TypeConverter to provide a drop down for the FavoriteModeOfTransportation, it is populated by just getting the InstanceName for each of the Transports. What I would like to accomplish is that when the user selects a Transport the property window would update to show a field for each of the "CustomOptions"

So if the user selects "Car" then the property window would allow the user to enter a value for:

Color (string)
HybridEngine (bool)
NumberOfDoors (int)

I hope that makes sense. I'm sure it is possible because I see similar things happening in the nupattern authoring experience. I'm just having trouble finding clues for how to make it happen.

Thanks,
Fred Pabon
Coordinator
Jul 29 at 10:52 PM
In NuPattern, we do it by extending heavily the System.ComponentModel type descriptors, by implementing ICustomTypeDescriptor (or registering a TypeDescriptorProvider, don't remember).

You might be able to register (statically, with AddProvider http://msdn.microsoft.com/en-us/library/1x0wz2y6(v=vs.100).aspx) your own, and dynamically add the additional properties, and intercept the user setting them via custom PropertyDescriptors (we do have base clases for all that, since we use that same approach ourselves).

But it's an advanced scenario that doesn't have any additional support in NuPattern beyond just .NET ComponentModel...


/kzu