I have a quite complicated issue in my advanced PropertyGridControl, but I managed to strip all extra code and still mantain in the same behavior as in my original project.
I attached an sample project which is actually an example where I reproduced the issue.
In my original project I face the situation, when a dependency property with the TypeConverterAttribute defines the specialized ExpandalbeObjectConverter which behaves in the following manner:
1. The user selects a collection of paths (strings), these strings are unique indentifiers and nothing more is important about them right know .
These string are stored in the dependency property named LineSources, it will help to follow the explanation as this video will.
2. The LineSources property changes due a property cell editing.
3. Its change then generates another collection of extra objects, it is named LineStyleDefinitions and its every item is mapped to the original LineSources collection through the unique source identifier, but there is no other link and that collection is not browsable in the property grid control.
3. Then the specialized descendant of the ExpandableObjectConverter generates virtual properties (property descriptors in GetProperties method) which should virtually define the properties of the expandable object, the string collection known as LineSources
4. Those properties are actually those extra objects from the LineStyleDefinitions collection and every extra object has its own set of properties, I omit the details that they are provided using the TypeDescriptionProviderAttribute, because it is not relevant here.
So, everything is working fine so far except that there the issue showed up, it is a glitch or a bug, I really don't know, but when the provided collection of the line sources, the LineSources, is initially empty, then no property defintions are generated in the ObjectToPropertyDefinitionsSourceConverter, it is correct behavior. There are other converters and selectors, but I have already found out in my so far research, that this is the point where it is probably the source of my issue, because afterward editing the LineSources collection and adding any line source, then regardless the LineStyleDefinitions are generated, they never show in the property grid. The SelectedObject has to be changed to display that virtual properties, because it is needed to re-generate the properties tree and so the virtual ones.
I tried to perform the property grid invalidation calling my Refresh method, which actually calls the DataController.InvalidateSource internal method, which helped me this way refereshing the properties values and keeping the property grid in place (no collapsing/expanding/scrolling/etc.)
So the attached sample should present the same thing. Altough I did a lot of debugging and observed this scenario very toroughly and found nothing wrong. The virtual properties are being generated in the right moment while the value is being set in the property grid, but the PropertyDefinitionsSource of that parent property defintions is not updated, but I cannot figure why it is so. Reselecting the currently SelectedObject does the thing, but I don't know when it is really necessary to do it, becuase if the object once had the virtual properties, then clearing the LineSources collection and selecting the same identifiers again will not trigger this issue, but when the user selects new ones, the "deeper refresh" is required.
Please take a time and inspect this issue, I can provide any further explanation, but I feel that there has to be a flawless solution for this issue. Actually I guess that forcing the re-generating the property defintions will help, but I don't know how to regenerate the defintion for the single row.
Show all comments