This is a migrated thread and some comments may be shown as answers.

All attributes are ignored when PropertySetMode is not None, and the Item is IEnumerable

3 Answers 76 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
BENN
Top achievements
Rank 1
BENN asked on 01 Feb 2016, 10:13 AM

I saw that you create a dynamic object that wraps the items in the IEnumerable I supply.

None of the attributes is being passed to the dynamic object. As a result, the PropertyDefinition EditorAttribute is null, and if I look at PropertyDefinition.SourceProperty, then it has no attributes.

 

Let me start by explaining why these attributes are important in my case:

Due to compatibility, and for ease of development, I use the Browsable attribute in order to filter properties that we don't want (In that case, I filter out, in the AutoGeneratingPropertyDefinitions event, properties with either Browsable = false, or properties without the browsable property. With such way, I don't care if a property was added to the ViewModel. Instead of setting Browsable=False to lots of lots of properties, I only add True to those I want to show).

 

Another useful scenario:

On some properties, I want to put a slider (bound to an int), and I want to be able to control the Minimum, and the Maximum of the slider.

Currently, this is not possible using the EditorAttribute.

I've added a new custom attribute called PropertyValueAttribute, which gets a string of the property name, and the value (object), and on the FieldLoaded event, I use reflection in order to set the required properties into the actual editor.

 

These are just small examples of how the attributes can be used in these cases.

 

However, none of these attributes is being copied into the dynamic object, and furthermore, the editor itself is not being set (so I'm seeing the default editor supplied by you, if any...)

This surely looks like a bug.

 

 

Furthermore, is there any way of getting the instance of the dynamic object? (the Item property returns the IEnumerable, and if I want to do some biding to the dynamic object, then I can't).

 

 

Another question:

If I decide to work in Unbound mode, then I need to create my own PropertyDefinition, but I cannot supply the EditorAttribute to it (since this property is internal/private).

I don't want to use EditorTemplate, since I already have the attribute in ViewModel and it contains the type of the editor and the name of the property in the control that is bound to the actual property in the view model.

Why is this EditorAttribute property inaccessible? (is there any good reason?)

 

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Feb 2016, 03:42 PM
Hi Benn,

We have been considering to respect the attributes when working with PropertySets for some time now, but most often than not we decide against it. The reason is that there are no specifications how to calculate which attribute to calculate. For example, if you have Fruit and Vegetable objects and both have property "Type" each with a different value for Browsable attribute, what should we respect? The same goes for every attribute.
Considering the EditorAttribute property of PropertyDefinition, it is expected to provide the attributes through the definition of the property, while specifying PropertyDefinition will require setting all you need on your own since you are creating a not-autogenerated one. 
 

Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
BENN
Top achievements
Rank 1
answered on 04 Feb 2016, 12:11 PM

Well, you could have checked if the ienumerable of items contains only one item, or if types with the same name uses the same editor.

 

I have had to work around this issue by turning off the "AutoGeneratePropertyDefinition", and merging (like just creating a large object with all the properties of the 2 items) the items with code done in the ItemChanged.

 

0
Maya
Telerik team
answered on 08 Feb 2016, 03:05 PM
Hello Benn,

Thank you for the suggestion. I logged the item in our feedback portal where you can follow its progress. We will research the case and schedule it based on the number of its votes.

Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PropertyGrid
Asked by
BENN
Top achievements
Rank 1
Answers by
Maya
Telerik team
BENN
Top achievements
Rank 1
Share this question
or