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
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.
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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
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.
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Example:
[AllowNested(
false
)]
IPAddress DeviceIP {
get
;
set
;}
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.
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
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.
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.
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.
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
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
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
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.