Hide nestedproperties

2 posts, 0 answers
  1. payal
    payal avatar
    8 posts
    Member since:
    May 2016

    Posted 30 May Link to this post

    I want to hide the properties which has nested properties inside them. What is best approach to do them? Ihave tries following things

    1. setting NestedPropertiesVisibility="Hidden" for radpropertygrid. But it not working.

    2. setting visiblility of propertydefinition based on displayname.The code looks like

    private void PropertyGrid1_AutoGeneratingPropertyDefinition(object sender, AutoGeneratingPropertyDefinitionEventArgs e)
              if (e.PropertyDefinition.DisplayName == "Mypropertyname")
                  e.PropertyDefinition.Visibility = Visibility.Hidden;  

    second approach works but I dont want to do on the basis of Displayname.I need to be hidden if any propertydefinition under property has nested property


    Would you please help me with the same.



  2. Dilyan Traykov
    Dilyan Traykov avatar
    334 posts

    Posted 31 May Link to this post

    Hello Payal,

    You can make use of the Browsable attribute in order to tell RadPropertyGrid to not display a certain PropertyDefinition. Here is an example:

    public class Order
        public string ShipAddress { get; set; }
        public string ShipCountry { get; set; }
        public string ShipName { get; set; }
        public string ShipPostalCode { get; set; }
        public Employee Employee { get; set; }

    The other approach, as you've guessed, is to handle the AutoGeneratingPropertyDefinition event. However, other than checking a hard-coded DisplayName value, the only available option is to check the PropertyDefinition's SourceProperty and base your logic on that.

    Would any of these approaches be suitable to your requirements?

    Dilyan Traykov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top