Question

Editor used in CollectionNewItem

Posted 10 days ago by Avatar Antoine Picard

Hi !

I saw there is an editor for list such as the one used in the grid sample, but I'm not able to find it in editors sample. Waht is the name of this editor ?

I have a specific class and I would like to use this editor for it.

Thanks !

AP

Information The latest build of this product (2018.1 build 0672) was released 27 days ago, which was before this thread was created.

Comments (6)

Posted 10 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Antoine,

We don't really have an editor dedicated to lists.  If you give me an exact example of what you're referring to in one of our samples, I can give you more information on what it is.


Actipro Software Support
Posted 7 days ago by Antoine Picard

Hi,

I was thinking about the example in the Grids sample called "Collection New Items". 

I checked the code and wasn't able to find any particular thing to display "Strings1", "Strings2" and "Strings3". There is the type converter but I don't think it's responsible of the display.

Thanks

AP

Posted 7 days ago by Antoine Picard

Ok so I managed to make it work by adding CollectionPropertyDisplayMode="EditableInline" to my PropertyGrid but my objects inside my list can't be removed and adding a new object doesn't trigger the PropertyValueChanged event.

Any tip or any idea why ?

AP

Posted 7 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Antoine,

Unfortunately that UI (the add/remove from collection buttons) is a feature of the PropertyGrid and isn't a standalone Editors control.

For PropertyGrid collection editing, please check out the "Collections" topic in the PropertyGrid documentation that comes with the product.  That talks about the CollectionPropertyDisplayMode property and covers other things like special events specifically for handling the adding/removing of collection items.


Actipro Software Support
Posted 6 days ago by Antoine Picard

Hi,

thanks for those informations, it helped me a bit but now I come with two new questions: (should I ask them here?)
- Is there a way to use this CollectionPropertyDisplayMode only with some of my Collection properties? By the dataFactory?
- I want to use a specific editor for list object by using something like this :

<grids:PropertyEditor PropertyType="List<Person>">
   <grids:PropertyEditor.ValueTemplate>
      <DataTemplate>
         <TextBox/>
      </DataTemplate>
   </grids:PropertyEditor.ValueTemplate>
</grids:PropertyEditor>

but it seems not to be the right syntax. Is there a way I can do that?

Thanks!

AP

Posted 6 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Antoine,

1) Our TypeDescriptorFactory.GetPropertyModels method will look at CollectionPropertyDisplayMode and if it is not Default, and the property type is a collection, it will call the factory's CreateCollectionPropertyModel method instead of CreatePropertyModel.  Thus you could probably override CreateCollectionPropertyModel and if you wish to block a property from getting the collection treatment, examine the arguments to that method and return the value of a call to CreatePropertyModel instead.

2) For the custom property editor, you can't specify generics that easily in XAML.  This StackOverflow topic might give you ideas on how to specify a generic type in XAML, or you could use the ObjectType and PropertyName options for specifying the applicable properties instead:

https://stackoverflow.com/questions/10005187/how-to-reference-a-generic-type-in-the-datatype-attribute-of-a-datatemplate

Also note that your TextBox in the DataTemplate would need additional bindings to the value, read-only state, etc.  Our Property Editors topic in the documentation gives an example.


Actipro Software Support

Add a Comment

Please log in to a validated account to post comments.