Welcome to the WPF feedback portal. We’re happy you’re here! If you have feedback on how to improve the WPF, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
Allow the user to participate in the PropertyGrid.SetEditor(...) process.
PropertyGrid allows assigning a custom editor based on property name, property type, or editor attribute. Property name requires listing all property names where the editor needs to be assigned, editor attribute requires modifying the model which may not be accessible, and property type doesn't support assigning an editor based on object base type, interface implemented, or open generic types.
PropertyGrid.SetEditor(...) does all of the work of assigning an editor to a property. It examines CustomEditorCollection based on property name and property type, it examines EditorAttribute, and failing finding an editor, it then examines the property type and assigns a built in editor.
It would be extremely useful if the user could participate in this process allowing editor assignment based on any examinable property the user chooses.
This could be property type, including the class base hierarchy, open or closed generics, any attributes or custom attributes, or even a property value within the object being edited (that may be hidden from the editor).
The easiest way to accomplish this would be to change
internal PropertyItem SetEditor(...)
to
protected virtual PropertyItem SetEditor(...)
So that a user could sub class PropertyGrid.
A more elegant, but slightly more complex approach, would be to add a "CustomEditorSelector" delegate or class property similar to how a DataTemplateSelector works.
delegate ITypeEditor CustomEditorSelector(PropertyItem propertyItem, PropertyDescriptor propertyDescriptor, object objItem);
or
abstract class CustomEditorSelector
{public abstract ITypeEditor SelectEditor(PropertyItem propertyItem, PropertyDescriptor propertyDescriptor, object objItem);
}
Using a property to set the selector would allow setting CustomEditorSelector in XAML
public CustomEditorSelector CustomEditorSelector { get; set; }The delegate or class, if not null, would be called at the beginning of PropertyGrid.SetEditor(...) and if the return is not null, that editor is used and the editor assignment is complete.