Posted 14 years ago
by Samuel T
-
Software Engineer,
Emerson Process Management
Hi,
I have a quick question. I have a generic object.
The properties of the object can only be known at runtime. (# of properties & types)
I'm trying to build a dynamic "edit property fields" dialog. Given that particular object, I would like to have the dialog auto-populate with the corresponding fields (depending on the types of the properties). For example: I want to render a BrushPropertyEditor for typeof(Brush), TextBox for typeof(string) and so on.
From what I understand, there are several options available. EditorAttribute is one of them(directly on properties, or via a custom TypeDescriptor or data factory), but I'm not sure if it's a good idea to carry this EditorAttribute on my data model.
Another that I can think of is to create a DataTemplate/Style which will apply the correct Editor based on the object type.
What would you recommend?
Thanks.
I have a quick question. I have a generic object.
The properties of the object can only be known at runtime. (# of properties & types)
I'm trying to build a dynamic "edit property fields" dialog. Given that particular object, I would like to have the dialog auto-populate with the corresponding fields (depending on the types of the properties). For example: I want to render a BrushPropertyEditor for typeof(Brush), TextBox for typeof(string) and so on.
From what I understand, there are several options available. EditorAttribute is one of them(directly on properties, or via a custom TypeDescriptor or data factory), but I'm not sure if it's a good idea to carry this EditorAttribute on my data model.
Another that I can think of is to create a DataTemplate/Style which will apply the correct Editor based on the object type.
What would you recommend?
Thanks.