Hi,
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?
Thanks
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?
Thanks
5 Answers, 1 is accepted
0
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
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 >>
0
Roman
Top achievements
Rank 1
answered on 09 Dec 2011, 02:39 PM
Hi,
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?
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?
0
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
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 >>
0
Peter
Top achievements
Rank 1
answered on 11 Jun 2014, 02:36 PM
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.
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.
0
Hi,
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?
Regards,
Ivan Ivanov
Telerik
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?
Regards,
Ivan Ivanov
Telerik
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.