Been having a bunch of problems lately - infragistics/hierarchical/etc. and one thing came to mind that I oddly enough hadn't thought about before.....
In my property Sets I call PropertyHasChanged which, in turn, calls OnPropertyChanged. Now, say I have a property "Name" I'll call PropertyHasChanged("Name") whenever it changes. But what happens if the changing of Name causes other values on the object to change?
This is a dumb example but say I have a property NumberOfCharactersInName. As Name changes so too does this. But no notification of this goes out so bound items may not update themselves.
This is problematic because:
1. I don't want to have to call multiple PropertyChangeds for every property because:
a. I don't think want a million events being raised - especially when things are in Lists, etc.
b. I don't want every property to have to know about other properties that are dependent on them - kind of breaks the observation idea.
2. I don't, either, want to have to call PropertyChanged(null) because I'd basically have to call that always (see b. in 1. above).
Thoughts?
Ok thanks for the clarification - I'd say (but could be wrong) that I'm not alone in raising events for only the property that has changed and not thinking what other properties are using the value of this because they must also raise events. My use of the word "observe" here was probably incorrect - in that example I was thinking mostly of calculated properties. But I do have a lot of parent observing child / object observing associated object scenarios which must get extra complicated i suppose.
Seems then that the safest thing to do is raise PropertyChanged(this, null) mostly - just hate the idea of writing code to say....Name changes so then x, y, z have probably changed too because it means that Name must know about those other properties rather than the other way around.
Thanks for the reply.
Copyright (c) Marimer LLC