AutoGeneratePropertyDefinitions="true", templates, tooltips

14 posts, 0 answers
  1. Branko
    Branko avatar
    18 posts
    Member since:
    Feb 2012

    Posted 24 Feb 2012 Link to this post

    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
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Feb 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Branko
    Branko avatar
    18 posts
    Member since:
    Feb 2012

    Posted 24 Feb 2012 Link to this post

    Hello Ivan,
    I mean, using custom editor like this defined as attribute,        
    [Editor(typeof(MyIntEditor), typeof(PropertyValueEditor))]
    
    Thank you,
    Branko 
    
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Feb 2012 Link to this post

    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 >>
  6. Branko
    Branko avatar
    18 posts
    Member since:
    Feb 2012

    Posted 27 Feb 2012 Link to this post

    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
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 29 Feb 2012 Link to this post

    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 >>
  8. Enrico
    Enrico avatar
    10 posts
    Member since:
    Oct 2011

    Posted 25 May 2012 Link to this post

    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.



  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 28 May 2012 Link to this post

    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 >>
  10. Enrico
    Enrico avatar
    10 posts
    Member since:
    Oct 2011

    Posted 29 May 2012 Link to this post

    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.



  11. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 30 May 2012 Link to this post

    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 >>
  12. Enrico
    Enrico avatar
    10 posts
    Member since:
    Oct 2011

    Posted 30 May 2012 Link to this post

    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.
  13. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 04 Sep 2013 Link to this post

    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();
  14. Peter
    Peter avatar
    37 posts
    Member since:
    Dec 2011

    Posted 14 Jan 2014 Link to this post

    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!
  15. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 17 Jan 2014 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready