Hi,
I have a problem showing the right editor für the properties for items inside a collection.
For RadPropertyGrid.Item I set a collaction.
The items of the collection has some EditorAttribtes set.
But at the ProbpertyGrid the Attribute is ignored.
Is there anything I can do to get this working?
private
void
Grd_OnSelectedCellsChanged(
object
sender, GridViewSelectedCellsChangedEventArgs e)
{
PropGrid.Item =
new
List<Test> {
new
Test {Name =
"N1"
, Number = 1},
new
Test {Name =
"N2"
, Number = 1}};
}
public
class
Test
{
public
string
Name {
get
;
set
; }
[Telerik.Windows.Controls.Data.PropertyGrid.Editor(
typeof
(TextBlock), EditorStyle.Modal)]
public
int
Number {
get
;
set
; }
}
3 Answers, 1 is accepted
Looking at the provided code snippet you have applied a collection to the RadPropertyGrid. The control does not support showing properties of the items inside a collection. The RadPropertyGrid can be used for one object only. In your case, you can use the CollectionEditor control. You can read more about this control in the CollectionEditors help article in our documentation.
Regards,
Dinko
Progress Telerik
Hi Dinko,
thanks for your reply.
But isn't the PropertySet exactly for that?
Because if I set the PropertySetMode to Intersection or Union I get all the properties from the items of the collection. Also multi edit is working. But the EditorAttribute is ignored.
Regards, Lukas
You are correct that you can use the PropertySetMode property to show the properties of items inside a collection. I have overlooked that and please accept my apologies.
Regarding your scenario. The EditorAttribute is ignored when PropertySetMode is used. Basically, in your case, you have a collection of one and the same objects. But you can set a collection to the PropertyGrid of different objects which have different EditorAttribute set to their properties. There is no built-in logic which can specify which EditorAttribute is more important than the other.
Regards,
Dinko
Progress Telerik
Hello Dinko,
In regard to Lukas' scenario, is there any way to manually decide which EditorAttribute pick? Or if this is not feasible which should be the correct way to intersect/merge a collection of custom properties?
Regards,
Albino
I am not sure that I understand what you mean by asking how to manually decide which EditorAttribute to pick. Can you elaborate a bit more on this?
The EditorAttribute is applied per property which means that the corresponding editor will be used only with that specific property. Also there is no option in the EditorAttribute that allows selecting an editor based on a condition. In case you want more freedom when it comes to editors, you can use the EditorTemplate.
If you want to provide a list different objects with intersecting properties, you can check the PropertySetMode.
To provide a custom list properties to be displayed in the PropertyGrid, then you can define the PropertyDefinitions manually.
Hello Martin,
I need to use the Property Grid to show the properties of different types of objects, each one with their properties. By giving the possibility to either select just one object and see just its properties or choose two or more objects of the same type and see an intersection of their properties. For some properties I've defined a template and assigned to the properties by using the attribute [Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(EditorName))]. If I bind the Property Grid with just an object I can see the properties with the correct EditorTemplate, but if I try to bind it with a collection of objects and using any type of PropertySetMode I will lose the EditorTemplate and any other attributes that I assigned to the properties like [MergeableProperty(false)].
So the question is:
if the problem is during the intersection operation, is there any way for me to customize this function? Or should I do the intersection manually and then give the Property Grid just the merged object?
Otherwise is there any better way to solve my problem?
Regards,
Albino
Hi Albino,
The most convenient way to manually adjust the displayed properties with all their customizations would be to create the PropertyDefinition objects manually when you change the Source value. This way you can check the new value in the Source and based on its type created whatever definitions you need.