This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I see you've recently dealt with the issue of dynamic properties in thread http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=2786 and a year ago in thread http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1596. In these two other threads you enumerated three general approaches to the problem: 1) ICustomTypeDescriptor, 2) ObservableDictionary<T> of properties, and 3) Directly adding nodes. I think the two threads thoroughly covered approaches 2 and 3, but I'm working more on approach 1. |
|
|
Hmm, this is a rather nasty one. We don't automatically reload the set of properties after a property changes, because this is likely to mess up things like focus and selection; and there's no standard way for an object to tell us that one of its properties has changed type rather than just value. So at the moment you do need to explicitly force the grid to re-read the subproperties: we don't do it automatically. Worse still, there isn't any particularly elegant way to invoke this re-read. The refresh functions are currently internal, and the only way to force a refresh is to reassign SelectedObject or to collapse and re-expand the tree item corresponding to the property that has changed type (which at least avoids a complete reset of the UI). We could expose the refresh functions more directly, but it's still not very MVVM-esque. So I'm open to suggestions on how we could handle this. One possibility is to allow a declaration on the grid that a particular property needs to have its children refreshed whenever it changes, e.g. <!-- hypothetical --> Another is to define an event similar to PropertyChanged that objects would raise to tell us to refresh -- that would enable us to avoid a reload if you changed between two instances of DataSource1 rather than between a DataSource1 and a DataSource2, but has the downside of coupling your data object/view model to our property grid, which again is not very MVVM. I'd welcome feedback on these options or any other suggestions you have -- obviously I know you'd like it to just happen, but that's probably not practical given that most types and properties are not dynamic and we don't want to compromise the common case in favour of the dynamic case. |
|
|
Offhand, I'm pretty comfortable with the event model you described, something like TypeChanged or SchemaChanged that I can send out whenever DataSource not only changes but changes type, which would cause you to refresh the children (I hope you'd be able to leave the subtree expanded). I'm new to MVVM but it doesn't seem to violate the spirit too badly. Only the VM (not the model) would need to implement this behavior and the whole point of the VM is to support the view, right?
kd |
|
|
Hmm, looks like I spoke too soon. It appears that we do already support this scenario after all, without any need for an extra interface or event. Sorry for the confusion! If you're using a current nightly build (or anything later than build 12460, released in November 2009), then this should Just Work (TM). So if you're on RTM, please upgrade to the latest nightly build and see if that fixes things for you. If you're already on a recent nightly build, and it's still not working for you, let us know and we'll see if we can figure out what's going on. |
|