Editor DataTemplate

6 posts, 0 answers
  1. Frank
    Frank avatar
    7 posts
    Member since:
    Jun 2009

    Posted 05 Sep 2011 Link to this post


    I'm trying to use the RadPropertyEditor for the first time. I have a simple business object with 5 Color properties. The RadPropertyEditor shows a standard TextBox (not a RadColorPicker) and if I try to update the color hexa the new value is not pushed back to my business object. I then try to use an EditorTemplate by intercepting the AutoGeneratingPropertyDefinitions event and set the Editor property. However I'm not able to figure out how my DataTemplate should like. The Rad WPF example use this:

    <DataTemplate x:key=foregoundTemplate>
       <telerik:RadColorPicker SelectedColor={Binding Path=Foreground ...

    This is not very extensible since the editor template needs to know the path of the property it's bind to. I don't want to make an editor for each of my 5 properties.

    Do I missing something?

  2. Ivan Ivanov
    Ivan Ivanov avatar
    1114 posts

    Posted 07 Sep 2011 Link to this post

    Hello Francis,

    Actually RadPropertyGrid provides default editors for several types only. However, you can easily design your own editors that execute custom logic. Please, refer to RadPropertyGrid's FirstLook example. It demonstrates how to use a RadColorPicker editor to modify Color type properties.

    Kind regards,
    Ivan Ivanov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft R3 2016 release webinar banner
  4. Roman
    Roman avatar
    2 posts
    Member since:
    Oct 2011

    Posted 09 Dec 2011 Link to this post

    I have the same issue as Francis.If I have a class like:
    public Test
    public Person A { get; set;}
    public Person B { get; set;}

    I would like to use the same DataTemplate for A and for B as I always want to have the same Editor for the type Person. This is not possible! (Or I haven't found a solution yet). 

    Currenty I have to define two DataTemplates to achieve it:
    <DataTemplate x:Key="A"><TextBox Text="{Binding A}"/></DataTemplate>
    <DataTemplate x:Key="B"><TextBox Text="{Binding B}"/></DataTemplate>

    I would expect to that it is possible to do that:
    <DataTemplate x:Key="B"><TextBox Text="{Binding .}"/></DataTemplate>

    Is there a way to set a EditorTemplate for a type? 

  5. Ivan Ivanov
    Ivan Ivanov avatar
    1114 posts

    Posted 12 Dec 2011 Link to this post

    Hi Roman,

    Currently RadPropertyGrid does not support native type mappings for editors. We have planned to introduce DataTemplate selectors for PropertyGridField with our next Q release. However, I have prepared a project for you that illustrates a possible workaround for such a scenario. Would you please confirm whether this approach would be applicable in your case?

    Best wishes,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Peter
    Peter avatar
    37 posts
    Member since:
    Dec 2011

    Posted 11 Jun 2014 in reply to Ivan Ivanov Link to this post

    Hi Ivan,

    I was struggling with the same problem, but your workaround is doing well!

    Has Telerik meanwhile integrated some improvements? 

    When Autogenerating RadDataForms, it is quite nice: You can set for a Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArg e simply e.DataField.Content = new MyUserControl() and there you are. So no need to generate a DataTemplate programmatically. It would be cool if this worked for RadPropertyGrids as well.

    BTW: FrameworkElementFactory class you are using in your workaround is marked as deprecated. So it would be nice if Telerik had done something to facilitate Autogeneration of RadPropertyGrids in this aspect.

  7. Ivan Ivanov
    Ivan Ivanov avatar
    1114 posts

    Posted 16 Jun 2014 Link to this post


    As an alternative to FrameworkElementFactory. You can load DataTemplates at runtime from strings with XamlReader.Load() Can you please confirm whether this approach works for you?

    Ivan Ivanov
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top
DevCraft R3 2016 release webinar banner