Hide certain NestedProperties

14 posts, 0 answers
  1. Brian Pratt
    Brian Pratt avatar
    28 posts
    Member since:
    Apr 2010

    Posted 01 Nov 2012 Link to this post

    I want to hide some nested properties (For example "IPAddress" properties).
    In short, I want to see the IPAddress property, but I don't want it to be a nested property.

    I've tried this, but it doesn't work.  Any suggestions on how to accomplish it?  I've attached a screenshot too.
    private void PropsGrid_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
    {
        string[] hiddenProperties = { "RotationAngle", "IsSelected", "Position", "Visibility", "Width", "Height", "Content", "Background" };
        if (hiddenProperties.Contains(e.PropertyDefinition.SourceProperty.Name))
        {
            // I want to hide some properties of the inherited object (this works)
            e.PropertyDefinition.Visibility = System.Windows.Visibility.Collapsed;
        }
        else if (e.PropertyDefinition.SourceProperty.PropertyType == typeof(IPAddress))
        {
            // I want to show IP address, but do not want them to expand NestedProperties
            // THIS DOESNT WORK
            e.PropertyDefinition.NestedProperties = null;
        }
    }
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 06 Nov 2012 Link to this post

    Hello Brian,

     You can check this forum post. Although it is for Silverlight, I think it will be helpful for you.

     For your convenience I have prepared a sample project targeting WPF. Please find it attached. 

    All the best,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Brian Pratt
    Brian Pratt avatar
    28 posts
    Member since:
    Apr 2010

    Posted 06 Nov 2012 Link to this post

    Thanks for the answer, but I see now the confusion my question raised.

    Hopefully this will clear up my question.

    I want to make the property not nested, but still visible.  I do not want certain properties to show a nested [+] box next to them.  In the case of the IPAddress, if it is nested, it throws an exception when you try to expand it (and there should be no reason to expand it).  I can get around this by changing the property to a string, but I really would like to keep it the type that it actually is.

    In short, I want to see the IPAddress property, but I dont want it to be a nested property.

    Hope that clears things up.
    Brian
  5. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 08 Nov 2012 Link to this post

    Hi Brian,

     The correct approach is:
    You can set AutoGeneratePropertyDefinitions to false and define the properties in your XAML. In this way you can remove the nested property definitions of certain property. Check the attached project for reference.


    Regards,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Brian Pratt
    Brian Pratt avatar
    28 posts
    Member since:
    Apr 2010

    Posted 13 Nov 2012 Link to this post

    If that is the "correct" approach, then may I suggest you add a property decoration that allows properties to be ignored by the Nested property code.  With hundreds of different types, with the capability to dynamically add even more, it would be silly to not allow the property grid to AutoGeneratePropertyDefinitions the fields. (as opposed to me defining hundreds of different property grid definitions in XAML).

    Example:

    [AllowNested(false)]
    IPAddress DeviceIP {
    get;set;}
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 16 Nov 2012 Link to this post

    Hi,

    Well, it is far from the best approach, so we will consider the usage of an attribute to deal with this. The Browsable attribute seems to be perfect for this purpose. Thank you for sharing your feedback with us. I have added 1000 telerik points to your account accordingly. I will keep in touch with you to notify you of any updates.

    All the best,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Alan
    Alan avatar
    25 posts
    Member since:
    Jan 2013

    Posted 07 Feb 2013 Link to this post

    Has RadPropertyGrid support for annotations to control nesting like suggested been implemented?

    I also would like to get rid of the "+" and do everything via code behind or attributes on the properties themselves.

    Doing this all inside of XAML isn't very practical for more dynamic cases.

    Thanks,
     Alan
  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 12 Feb 2013 Link to this post

    Hi,

    Our initial idea to deal with such scenarios was to check whether all of the nested properties are browsable or not. However, this will hardly work well when dynamic properties are used. We will consider introducing a more general alternative. It will possibly be available at some moment between the release of Q1 2013 (the last week of Feb) and the SP.

    Greetings,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Larry
    Larry avatar
    12 posts
    Member since:
    Dec 2009

    Posted 05 Apr 2013 Link to this post

    Any updates on this one, now that we get sp?

    I rechon with Alan that this is important feature. In my case I do want the property definitions autogenerated, (so I can switch data item of different sub types on the fly). Also I want some complex properties show as nested(a nice feature), but for some properties I want to create a custom editor for it so no nesting is needed.
  11. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 10 Apr 2013 Link to this post

    Hi,

     This behavior will be available with the next week's internal build. It will be available on Monday/Tuesday.

    Greetings,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  12. Brian
    Brian avatar
    6 posts
    Member since:
    Aug 2014

    Posted 01 Oct 2014 Link to this post

    Was this added?  I want to auto generate the property definitions, and I want to show nested properties for most properties, but for some (for example, a collection property) I want to hide their nested properties, so a suitable attribute as mentioned by Brian Pratt above would be perfect.

    The last answer said "this behaviour" would be available in the next build, and that was over a year ago, so what behaviour was added?

    Thanks,

    Brian
  13. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 06 Oct 2014 Link to this post

    Hello Brian,

    The behaviour that my colleague had mentioned is PropertyGird's support for - Auto-generated NestedProperties for IDynamicMetaObjectProvider types (DynamicObject)

    As for you question: you can use the mentioned Browsable attribute. Please check the attached project for a reference.

    Regards,
    Yoan
    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.
     
  14. Brian
    Brian avatar
    6 posts
    Member since:
    Aug 2014

    Posted 06 Oct 2014 in reply to Yoan Link to this post

    Hi Yoan,
    The nested property I wish to hide is not part of my code, in fact it's the Count property for a List, so I can't add an attribute to it.  What I would like to be able to do is add an "AllowNested(false)" attribute (as a previous poster suggested) to my List property, and have this prevent the nested attributes for the List from being displayed, while still allowing my other custom properties to display their children.
    Thanks,
    Brian
  15. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 08 Oct 2014 Link to this post

    Hi Brian,

    Please excuse me for misleading you.

    I am afraid that this functionality is not supported since there are some conceptual impediments that prevent us to change the implementation of RadPropertyGrid. However, I have logged this in our system as feature request. You can find it on our feedback portal and vote for it: Add an attribute to control whether a property definition has nested property definitions


    Regards,
    Yoan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready