Multiple Items - DataTemplateSelector

2 posts, 0 answers
  1. FrimaStudio
    FrimaStudio avatar
    1 posts
    Member since:
    Nov 2012

    Posted 23 Apr 2013 Link to this post


    Today, I added support for multiple selection in our tool. We are using the WPF RadPropertyGrid. 

    So we modified the control to use :
    SelectionMode="Multiple" and PropertySetMode="Intersection".

    I am using the EditorTemplateSelector to select a custom editor for some class types such as "Point".

    Before I did this when the PropertyGrid is in single selection mode:

    if (item as PropertyDefinition != null && (item as PropertyDefinition).SourceProperty.PropertyType == typeof(System.Windows.Point))
    return PointPropertyDataTemplate;

    Now, with multiple selection, the SourceProperty.PropertyType is always of type System.Object. I understand it is now pointing to a dynamic model but it is still be important to keep the original type somewhere else in the parameter. It doesn't make sense to me to add a massive switch case with ALL (over 400) parameters hardcoded "names", and this create software very hard to maintain. I've read that you are working on the Editor Template Attribute that we could set in code but still I want to rely on the class type for single and multiple selection to avoid filling code with redundant attribute.

    Do you have any suggestion for this? 

    Also, having new converters for every class type when using multiple selection is also making my software filled with dozens of converter classes. Why is multiple selection absolutely require this as the property of every selected object is of the same type.

    Thank you

  2. Ivan Ivanov
    Ivan Ivanov avatar
    1201 posts

    Posted 26 Apr 2013 Link to this post


     Unfortunately, our current implementation of this feature relies exclusively on dynamic properties (there is an implementation of DynamicObject behind) and DLR do not provide any information about the underlying property type. We have a few ideas about improving this behavior in future versions by replacing it with ICustomTypeProvider, but such a feature is not yet officially planned. I will keep you in touch in case there is any progress on this.

    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top