This is a migrated thread and some comments may be shown as answers.

AutoGeneratePropertyDefinitions="true", templates, tooltips

13 Answers 177 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Branko
Top achievements
Rank 1
Branko asked on 24 Feb 2012, 03:42 PM
Hello,

When AutoGeneratePropertyDefinitions="true", how to use custom made templates for error handling on properties that where auto generated?
Custom editors for values and tooltips ?

Thank you,
Regards,
Branko

13 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 24 Feb 2012, 04:02 PM
Hi Branko,

Would you please clarify what do you mean by this: "custom made templates for error handling"?

Greetings,
Ivan Ivanov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Branko
Top achievements
Rank 1
answered on 24 Feb 2012, 04:27 PM
Hello Ivan,
I mean, using custom editor like this defined as attribute,        
[Editor(typeof(MyIntEditor), typeof(PropertyValueEditor))]

Thank you,
Branko 
0
Ivan Ivanov
Telerik team
answered on 24 Feb 2012, 04:47 PM
Hi Branko,

Our recommended approach in such scenarios is to use a DataTemplateSelector, in order to select
the proper editor DataTemplates according to properties' types. Please refer to the following demo: demos > RadPropertyGrid > "DataTemplateSelector support" that illustrates how to achieve this. Currently we do not have plans to support the Editor attribute.

Regards,
Ivan Ivanov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Branko
Top achievements
Rank 1
answered on 27 Feb 2012, 07:00 PM
Hi Ivan,
This is the summary, I do not know if I am wrong somewhere. Most of Attributes that I have specified are the attributes that I would like to work with. Comment and question are in line with code ?! Working with attributes is needed, If I have several objects with more then 50 properties per object then I should work with attributes.

<telerik:RadPropertyGrid x:Name="propertygrid1" Item="{Binding Selected}" AutoGeneratePropertyDefinitions="True">           


[Browsable(true)]//Working
[ReadOnly(true)]//Working
[Description("Current distance between camera and object")] //Working
[Display(Name = "Distance", GroupName = "Group1")] // Working
[Range(10, 20)] // Does not work. !? No Integrated Error message ? Would be nice if it is integrated in ToolTip, similar to MaskedInputTextBox.
[StringLength(15, MinimumLength = 5, ErrorMessage = "ERROR : Please enter a valid title.")] // Does not work, if the property is string.
[CustomValidationAttribute(typeof(TestItemValidatior), "ValidateIntProperty")] // It is working, but trowing validation exception it is not so nice. Would be better if it is in ToolTip ! How to make it in ToolTip?
[DefaultValue(59)] // Not working! How to make it ?
[Required(ErrorMessage="This Field is required")] // I do not know if it works. Where can I see this error message ?
[Editor(typeof(MyIntValidator), typeof(PropertyValueEditor))] // Does not work, you have told me that you do not suppport custom Editors !
[MyIntValidationIf(typeof(MyValidation))] // No support for self made attributes ?
public int Distance
{
    get { return _distance; }
    set
    {
            Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "Distance" });
            _distance = value;
    }
}

Regards,
Branko
0
Ivan Ivanov
Telerik team
answered on 29 Feb 2012, 03:38 PM
Hello Branko,

All the validation exceptions are treated equally by RadPropertyGrid. DataAnnotations validation attributes provide a "named parameters" constructor, where you can specify your error message, so that no "Integrated Error message" is needed in my opinion. As for any custom validation solutions, we recommend the CustomValidation attribute that I have demonstrated in the attached project from the other support thread of yours. We believe that it provides flexible enough logic. Unfortunately, with the current version of RadControls, RadPropertyGrid lacks a proper way of displaying the validation error messages. However, we plan to introduce such (possibly a validation summary) with the incoming service pack of Q1.

Regards,
Ivan Ivanov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Nicola Tramarin
Top achievements
Rank 1
answered on 25 May 2012, 09:50 AM
Hi Ivan,
I have the same requirements as Branko.
Specifically the issue I have is related to what you said: "Unfortunately, with the current version of RadControls, RadPropertyGrid lacks a proper way of displaying the validation error messages".
I have downloaded the latest release Q1 2012 SP1(version 2012.1.326).
I there a way to display error message with a tooltip as similar to the RadGridView for example?
I was searching a way to do that with the RadPropertyGrid but I couldn't find it.
Any help would be appreciated.

Regards

Enrico Trombetta
Software Developer 
CAE S.p.A.



0
Ivan Ivanov
Telerik team
answered on 28 May 2012, 12:10 PM
Hi Enrico,

WPF's does not provide default validation tooltips/indicators for most of the input controls. As you have pointed out, RadGridView visualizes such errors, utilizing some additional template elements - EditorPresenters. Unfortunately there are some conceptual differences between PropertyGridField and GridViewCell that make such an approach quite ineffective. Currently we are working on a validation-summary-like feature that would summarize and visualize the input errors. Unfortunately it was a bit delayed in favor of some more requested features, but it should be ready in the close future.
As a temporary workaround you may try implanting a custom tooltip like the one discussed in this forum thread.

All the best,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Nicola Tramarin
Top achievements
Rank 1
answered on 29 May 2012, 07:37 AM
Hi Ivan,
I've already tryed implanting a custom tooltip like the one discussed in the forum thread, but although I can make it work easily with Validation Rules (the standard WPF validation mechanism), the same is not true for your CustomValidationAttribute.
What I was trying to do is use your CustomValidationAttribute and implanting the tooltip myself.
The CustomValidation throws exceptions and I don't know how to set up property Validation.HasError to show errors using the tooltip.
So, are you suggesting to use Validation Rules instead?

Regards

Enrico Trombetta
Software Developer
CAE S.p.A.



0
Ivan Ivanov
Telerik team
answered on 30 May 2012, 09:16 AM
Hi,

I have prepared an example project for you that utilizes validation logic based on the CustomValidationAttribute. In my opinion DataAnnotations validation and framework's validation interfaces are quite more mature approaches than the Validation Rules mechanism. Please, refer to the attached project and let us know whether this would work for you.

Regards,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Nicola Tramarin
Top achievements
Rank 1
answered on 30 May 2012, 11:18 AM
Hi Ivan,
yes! This is exactly what I wanted to do.
And I agree with what you said, it's better to use DataAnnotations over Validation Rules that's why I was trying your CustomValidationAttribute.
Thanks a lot for your help, very appreciated!

Regards

Enrico Trombetta
Software Developer
CAE S.p.A.
0
Kristoffer
Top achievements
Rank 1
answered on 04 Sep 2013, 07:02 AM
Wouldn't it be possible to apply the EditorAttribute in code-behind?

1) Handle the RadPropertyGrid.AutoGeneratingPropertyDefinition event.
2) Find the EditorAttribute property of the grid's item.
3) Assign the EditorTemplate. I.e. e.PropertyDefinition.EditorTemplate = attributes.OfType<EditorAttribute>().FirstOrDefault();
0
Peter
Top achievements
Rank 1
answered on 14 Jan 2014, 03:00 PM
Hi Ivan,

you wrote in Feb 2012 "However, we plan to introduce such (possibly a validation summary) with the incoming service pack of Q1".
I'm using 3Q 2013 version and it still seems not to be possible to display validation results and messages in RadPropertyGrids.

Or am I doing something wrong? Please post an example!
0
Ivan Ivanov
Telerik team
answered on 17 Jan 2014, 11:26 AM
Hello,

Unfortunately, we had to drop this feature due to incompatibilities with RadPropertyGrid's template structure. Currently, we do not plan to release this feature in the close future. However, we will gladly help you to achieve similar custom behavior, if you are willing to tell us more about your scenario.

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PropertyGrid
Asked by
Branko
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Branko
Top achievements
Rank 1
Nicola Tramarin
Top achievements
Rank 1
Kristoffer
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Share this question
or