property editor for list of strings

Grids for WPF Forum

Posted 13 years ago by Mary Fontana - Rudolph Technologies
I have a class that has a list of values.

public MyClass
public string Name {get set; }

public List<string> Values {get;}


If I use the default prop editor, there is not a + for adding a string value.
I extended ExpandableObjectConverter with StringCollectionConverter to show in the Values field instead of "2 items" the names of the items such as "AA, BB"
But if I change the value of one of the items, the string "AA, BB" does not get modified.

Is there a prop editor for list of strings/numbers?

Any suggestions?

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mary,

The PropertyGrid needs to be notified that your Values property changed. You can notify it several ways:

1. Change Values to be an ObservableCollection and attach to the CollectionChanged event in MyClass. Then you'd need to implement INotifyPropertyChanged on MyClass and raise the PropertyChanged event for the Values property when it's collection is changed.

2. For the IPropertyDataAccessor to be refreshed from your custom ExpandableCollectionConverter when an item is added. Something like:
public class MyExpandableCollectionConverter : ExpandableCollectionConverter, ICollectionTypeConverter {
    bool ICollectionTypeConverter.AddItem(IPropertyDataAccessor propertyDataAccessor, object item) {
        if (propertyDataAccessor != null && this.AddItem(propertyDataAccessor, item)) {
            return true;
        return false;
Note: We've made the ExpandableCollectionConverter.AddItem method virtual for the next release, so you don't have to explicitly define the ICollectionTypeConverter method like above.

3. A custom DataFactory and property data accessors could also be used.

We can give you more information on #3 if you want, but your best bet would probably be option #1 or #2.

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.