Minimum requirements for EditableInline to work with a custom data factory/property descriptors

Grids for WPF Forum

Posted 11 years ago by Craig Rowe
Version: 13.1.0580
Avatar

I'm working with a custom data factory that creates it's own IPropertyDataAccessors (in DataFactory.GetProperties).

Can I confirm what the minimum requirement is to either ensure that I add (or ensure that I leave in place rather than unintentionally override) to allow CollectionDisplayMode="EditableInline" to both show the buttons and work.  Simply ensuring that CanAddChild is true on my observerablecollection property descriptor only shows the button.  However the button, when clicked, performs no actions.

What other aspects are required to ensure the +/- buttons, collection objects and collection object properties show and are editable when using a custom data factory? For example do the IPropertyDataAccessors returned for my parent object need to return additional items for the child object?

Thanks in advance, Craig

[Modified 11 years ago]

Comments (5)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Craig,

The general rule of thumb would be if you override CanAddChild to get the button enabled, then you have to override AddChild to make it work. Same goes for the CanRemove and Remove on the collection items.

Our ExpandableCollectionConverter actually implements the code that actually adds or removed items from a collection. This is simply a custom TypeConverter. For collections our default factories will create an instance of CollectionPropertyDescriptorDataAccessor (an IPropertyDataAccessor), and collection items end up wrapped in an instance of PropertyDescriptorDataAccessor (just like regular properties).

Both CollectionPropertyDescriptorDataAccessor and PropertyDescriptorDataAccessor check to see if they are a (or part of a) collection, then call into the TypeConverter to perform the add/remove.

If this doesn't help, please feel free to email a small sample over to our support email address and we can work through the details.


Actipro Software Support

Posted 11 years ago by Craig Rowe
Avatar

Hi,

Thanks for this I've been able to get this stuff working.  I now have a weird situation whereby the PropertyGridChildAdding, PropertyGridChildAdded and PropertyGridChildRemoving all fire and work however the PropertyGridChildRemoved does not appear to fire (or rather it does not appear to surface via the overal property grid PropertyChildRemoved event).  Debugging via reflector as far as I can go it does seem that the PropertyDescriptorDataAccessorBase calls OnNotify it just doesn't make its way out to my PropertyGrid level event handler. The UI does update - however I need to do some actions on removed

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Craig,

If you can please put together a small sample project and email it over to our support address, then we can take a closer look.

Thanks!


Actipro Software Support

Posted 11 years ago by Craig Rowe
Avatar

Hi,

It's kind of hard to untangle as it's in a large layered/abstracted setup.  I'd hoped there was some magic going on that you knew about between OnRemoving and OnRemoved.  My concern is that Parents or some other aspect of the accessors isn't quite setup properly in the data factory for the OnRemoved event to successfully bubble to the grid (and therefore my code).

 

Cheers

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Craig,

Yeah, unfortunately it's very hard to tell what the issue could be without seeing it in action so we can debug it. There are several parts working in tandem to raise the events, as well as forward them from the data abstraction layer (i.e. the data accessors) to the UI layer (i.e. the PropertyGridDataAcessorItem and PropertryGrid). This forwarding link also uses a custom WeakEventManager to prevent objects from being retained, so that adds more complexity as the link can be broken outside of our code.

The best way would probably be to make a copy of your project and tear out things that are not important to reproduce the issue and send that over. If we have a problem debugging it, then we will let you know.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.