Display changes made on nested properties

Grids for WPF Forum

Posted 11 years ago by Till
Version: 12.2.0573
Avatar

Hi!

I use a PropertyGrid to display all objects (their classes derive from class "A") which are bound to another object (class "B"). The amount of "A"s may change while a "B" is displayed. For this to work, I manually create PropertyGridPropertyItems with an "A" as value and add them to the PropertyGridCategoryItem's Accessors-collection.

I want the "A"s to be displayed differently, based on their actual type. This works for non-expandable "A"s using my own editors which are chosen upon the PropertyType. (That's why I assign the "A" to the PropertyGridPropertyItems' value and not just the to-be-displayed data of "A".)

Instances of the class "C" (which is derived from "A") have a list (property "Values") of integers which I want to be displayed as nested properties. Using my own TypeConverter (derived from ExpandableObjectConverter) the PropertyGrid offers me the possibility to expand "C"s and shows all of the integers as children. But I only get a kind of snapshot of the integers. When the values change the child-nodes are not updated. Nevertheless the value displayed at the "C"-node (a string containing all integers) gets updated. (This string is always created when a PropertyChanged of the "Values"-property is received.)

My TypeConverter creates instances of my IndexedValueDescriptor class (derived form PropertyDescriptor) and initializes each one of them with a display-name, a property-name and the index of the integer (inside the "Values"-list). The GetValue-method takes the provided object, uses reflection to find the property and returns the element described by the index.

I want that changes to the integers get visible when PropertyChanged for "Values" is fired. My first guess was that the values are not updated because nobody tells the PropertyGrid to do so. So I put a breakpoint to the PropertyDescriptor.AddValueChanged method to peek if something registers an eventhandler. Unfortunately, this is not the case. Firing the ValueChanged event periodically (just for testing purposes) showed no result.

Does anybody have an idea what I can try to get my desired result? A hint where to dig for a solution may be sufficient.

Thanks for your help,

     Till

Comments (3)

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

Hi Till,

Does your list implement INotifyCollectionChanged?  If so, I would probably expect PropertyGrid to get notified of the change, assuming you are manually creating the data accessors properly.


Actipro Software Support

Posted 11 years ago by Till
Avatar

Hello.

 

The list of integers does not implement INotifyCollectionChanged. But I think that is not the problem because I do not pass the list to the PropertyGrid but a PropertyDescriptor for each item inside the list.

Nevertheless, I created a small sample were I use an ObservableCollection<int> as container. But there is no change in the PropertyGrid's behaviour.

 

I am not sure if my approach is reasonable. At the end of the day, I want to display a list of items as nested properties and I want to be able to provide a DisplayName for each item. The naming (numbering from 0 to x) which I get by the default converters is not useful for me.

Have a nice day,

     Till

[Modified 11 years ago]

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

Hi Till,

Another idea for you... You should be able to build a custom DataFactory and override the CreateCollectionPropertyDataAccessor method.  You could inject a custom PropertyDataAccessor for your collection items that returns a custom DisplayName.  The rest would just fall into place (i.e. expanding collections, adding/remove, etc.).


Actipro Software Support

The latest build of this product (v24.1.2) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.