When I add PropertyDefinitions to the PropertyDefinitions member of a PropertyGrid, if they have NestedProperties, they are collapsed by default (i.e. the plus sign is visible, not the minus sign, and the nested properties are not yet visible). But when I add to the NestedProperties of a ProprtyDefinition, those properties are expanded by default (i.e. the minus sign is visible, and the nested properties are visible). Is there a way to control this? In most cases, I'd always want them collapsed by default (this would be much more performant, because it won't try to load everything at once), but ideally I'd use a property of the PropertyDefinition I'm adding, or of the PropertyDefinitionCollection I'm adding to, so I could have complete control of this.
Thanks,
-Ari
12 Answers, 1 is accepted
I have added a PropertyDefinition following this help article. The definition was initially collapsed. May I ask you to share haw have you added PropertyDefinitions to the PropertyDefinitions member of a PropertyGrid? Do you get the same behaviour using the latest binaries?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I'm using the property grid with AutoGeneratePropertyDefinitions set to false, and I'm also using my own EditorTemplates. Here's the xaml for the grid:
<
telerik:RadPropertyGrid
x:Name
=
"propertyGrid1"
Grid.Column
=
"1"
SearchInNestedProperties
=
"True"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
AutoGenerateBindingPaths
=
"False"
AutoGeneratePropertyDefinitions
=
"False"
NestedPropertiesVisibility
=
"{Binding IsChecked, ElementName=CheckBox1, Converter={StaticResource converter}}"
DescriptionPanelVisibility
=
"Collapsed"
Loaded
=
"propertyGrid1_Loaded"
/>
Here's a bit of code that give the simplest case of adding properties that reproduces the problem (not really realistic, as I've done a bunch of other stuff to get the EditorTemplates working, etc., but it will show you the problem):
var topPropDef1 =
new
PropertyDefinition() { DisplayName =
"Top1"
};
var nestedInPropDef1 =
new
PropertyDefinition() { DisplayName =
"InsideTop1"
};
var grandChildProperties = new PropertyDefinitionCollection();
grandChildProperties.Add(
new
PropertyDefinition() { DisplayName =
"InsideInsideTop1"
});
nestedInPropDef1.NestedProperties = grandChildProperties;
var childProperties = new PropertyDefinitionCollection();
childProperties.Add(nestedInPropDef1);
topPropDef1.NestedProperties = childProperties;
var topPropDef2 =
new
PropertyDefinition() { DisplayName =
"Top2"
};
propertyGrid1.PropertyDefinitions.Add(topPropDef1);
propertyGrid1.PropertyDefinitions.Add(topPropDef2);
Now, if you run that, what you'll get initially is a PropertyGrid where there are two properties, one with a plus sign called Top1, and that property will be collapsed. But if you expand Top1, by clicking on the plus sign, then the property underneath it, InsideTop1, will automatically also be expanded, and what I'd like is either the ability to control this, or to just always have all properties default to being collapsed. I think I see the reason why it works this way (before expanding a property in propertyGrid1.PropertyDefinitions, the properties inside of its NestedProperties are not even loaded yet, but when you expand, it's NestedProperties, and all of their NestedProperties are then loaded), but I'm wondering if it's possible to change this behavior. Basically, I want the NestedProperties in PropertyDefinitions to work the same way that the PropertyDefinitions in a RadPropertyGrid already work.
For what I'm developing this will offer a huge performance boost in most cases when a user clicks on the plus signs at the top-level. The ability to control this behavior will allow a user to either accept the performance hit, and have all properties expanded, or else, and by default, to make the user click each plus sign deeper in the hierarchy, and have fast performance clicking around, as only one level of hierarchy will ever expand at a time. This last is a nice to have, but the first part, defaulting to not expanding the NestedProperties, and their NestedProperties ad infinitum, is pretty important to how I'm using the PropertyGrid.
Thanks,
-Ari
Would you please confirm which version of RadControls you are currently using? Meanwhile, you can also check what is the value of the affected PropertyGridField's IsExpanded property.
Greetings,Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I'm using the 2012 Q2 version. The Product version I see on the dlls is 2012.2.0607.1050.
I had tried to alter the value of all the PropertyGridField's IsExpanded property. That's how I discovered the PropertyGridFields for the PropertyDefinitions of RadPropertyGrid.PropertyDefinitions are not added until those properties are expanded (i.e. when the user clicks the plus sign). That's ideal because it means that the control loads very quickly, even when there's a large hierarchy. It works that way for RadPropertyGrid.PropertyDefinitions, but not for PropertyDefinition.NestedProperties. The behavior of the PropertyDefinitionCollection in RadPropertyGrid (i.e. the PropertyDefinitions property) is very helpful to me, as I'm loading a large hierarchy, and if the same behavior can be applied to the PropertyDefinitionCollection in PropertyDefinition (i.e. the NestedProperties property), it would be also be very helpful.
Wow. That was a lot of use of the word property :).
Thanks,
-Ari
Please excuse me for the delayed answer. Let me shed some more light on RadPropertyGrid's loading mechanism. When AutoGeneratePropertyDefinitions is false and an hierarchy of PropertyDefinitions is defined, RadPropertyGrid loads PropertyGridFields based on the "visible" PropertyDefinitions (PropertyDefinitions are not visual objects. They serve as ViewModels for their PropertyGridField counterparts). When a filed is expanded, its nested fields are loaded (based on its nested PropertyDefinitions). This "load on demand" behavior saves a lot of resources during the initial load. Would you please confirm whether you have encountered any performance issues with RadPropertyGrid? If so, you can send us a sample project that we can debug and provide some guidelines.
Greetings,Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
The "load on demand" behavior is exactly what I need, just more of it. "Load on demand" only happens at the top layer of the hierarchy, i.e. "load on demand" happens on elements of RadPropertyGrid's PropertyDefinitions property, but the "load on demand" does not happen on properties of PropertyDefinition's NestedProperties property. As soon as you expand a property, all NestedProperty's (and all NestedProperty's of NestedProperty's ad infinitum) are loaded.
I'm not having large performance issues yet, though I can certainly produce an example that would lead to them. Basically, the PropertyGrid loads fast, because of the "load on demand", but when the user clicks on the plus sign next to top-level properties, there can be a big pause, because at that point, it loads all NestedProperties, rather than just the first level.
My post on 6/27 demonstrates what I'm talking about, on a very small scale that won't lead to a large pause, but I can easily expand that to do so, if it helps. Would it be enough if I just send you a bit more code for that example that will lead to the pause? I can send a whole project too, if you need, just tell me how you'd like me to send it.
Thanks,
-Ari
So, I added the bit of code to what I sent that will show you an unrealistic example of the possible performance hit from not doing the "load on demand" for NestedProperties. Here's the code:
var topPropDef1 =
new
PropertyDefinition() { DisplayName =
"Top1"
};
var nestedInPropDef1 =
new
PropertyDefinition() { DisplayName =
"InsideTop1"
};
var grandChildProperties =
new
PropertyDefinitionCollection();
for
(
int
i = 0; i < 150; i++ )
{
var grandChildPropDef =
new
PropertyDefinition() { DisplayName =
"InsideInsideTop"
+ i.ToString() };
var greatGrandchildProperties =
new
PropertyDefinitionCollection();
greatGrandchildProperties.Add(
new
PropertyDefinition() { DisplayName =
"InsideInsideInsideTop"
+ i.ToString() });
grandChildPropDef.NestedProperties = greatGrandchildProperties;
grandChildProperties.Add(grandChildPropDef);
}
nestedInPropDef1.NestedProperties = grandChildProperties;
var childProperties =
new
PropertyDefinitionCollection();
childProperties.Add(nestedInPropDef1);
topPropDef1.NestedProperties = childProperties;
var topPropDef2 =
new
PropertyDefinition() { DisplayName =
"Top2"
};
propertyGrid1.PropertyDefinitions.Add(topPropDef1);
propertyGrid1.PropertyDefinitions.Add(topPropDef2);
It's pretty easy to get this going in the NestedPropertyDefinitions example; just replace the propertyGrid1 xaml with what I'd sent on 6/27, and paste the above code into the constructor. If you'd like, I can zip up the project with this done, but it should be pretty easy for you to reproduce. Let me know.
If you run that code, you'll see that the PropertyGrid loads nice and fast. When you click the plus sign next to Top1, though, there is a pause, about 8 seconds when I tried it (if it still goes fast for you, just increase the iterations of the loop that loads grandChildren properties). What I'd like is a way to not have that pause then the user clicks on Top1, because the Top1 property only has one NestedProperty. Instead, the pause should happen when the user clicks on the plus sign next to InsideTop1, as that is the property that has many NestedProperty's underneath it. Even that one should go faster, of course, because it could only load it's own NestedProperty's, not the NestedProperty's of their NestedProperty's, when the plus sign is clicked.
Thanks,
-Ari
Please excuse me for the delayed reply. Would it be possible for you to assemble a sample runnable project and send it through our support ticket system, so that we could investigate it on our side? I believe that in this way it will be easier for both sides to discuss these requirements in a specific context.
All the best,
Ivan Ivanov
the Telerik team
But for the matter of fact, I am not getting any "IsExpanded" property in the RadPropertyGrid.
Please suggest something.
Unfortunately, we are not able to get the unwanted behavior on our side. May I ask you to open a support ticket and to send a simple runnable project demonstrating the problem?
Thank you in advance.
Regards,
Vera
Telerik
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 >>
Thanks,
Neelesh Vishwakarma
Hello Neelesh, we too face the similar issues of not catching up the IsExpanded event on PropertyDefinition, please let me know the solution that u had fixed.
Thanks,
Lakshman Siddireddy