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

Hide certain NestedProperties

13 Answers 130 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Brian Pratt
Top achievements
Rank 1
Brian Pratt asked on 01 Nov 2012, 03:31 PM
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;
    }
}

13 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 06 Nov 2012, 12:29 PM
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.

0
Brian Pratt
Top achievements
Rank 1
answered on 06 Nov 2012, 12:50 PM
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
0
Yoan
Telerik team
answered on 08 Nov 2012, 04:17 PM
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.

0
Brian Pratt
Top achievements
Rank 1
answered on 13 Nov 2012, 01:27 PM
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;}
0
Ivan Ivanov
Telerik team
answered on 16 Nov 2012, 04:40 PM
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.

0
Alan
Top achievements
Rank 1
answered on 07 Feb 2013, 08:48 AM
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
0
Ivan Ivanov
Telerik team
answered on 12 Feb 2013, 09:24 AM
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.

0
Larry
Top achievements
Rank 1
answered on 05 Apr 2013, 08:38 PM
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.
0
Ivan Ivanov
Telerik team
answered on 10 Apr 2013, 03:37 PM
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.

0
Brian
Top achievements
Rank 1
answered on 01 Oct 2014, 09:42 AM
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
0
Yoan
Telerik team
answered on 06 Oct 2014, 09:20 AM
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.
 
0
Brian
Top achievements
Rank 1
answered on 06 Oct 2014, 09:37 AM
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
0
Yoan
Telerik team
answered on 08 Oct 2014, 04:17 PM
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.

 
Tags
PropertyGrid
Asked by
Brian Pratt
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Brian Pratt
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Alan
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Share this question
or