Custom Class stored in Managed Property, do I need INotifyChildChanged ?

Custom Class stored in Managed Property, do I need INotifyChildChanged ?

Old forum URL: forums.lhotka.net/forums/t/6361.aspx


sroberts posted on Friday, February 06, 2009

Similar to how you can store a SmartDate in a managed property, I have created my own class that provides more functionality than a simple .NET base type. As well as being able to set the internal property of the class (via a public Set on the class) it has a couple of methods I can access. I have the convienience of storing the data I need in that class, but also have some related methods I can call, all from the instance of the property in the parent Business Object.

My problem is that I update the value in the class through its public Set method my parent business object does not become Dirty. However if I breakpoint and examine the property I can see it has my new value (it's data bound via a combobox and all of this is working great)

Do I need to impliment INotifyChildChanged in my custom class or is there something else I'm missing.

RockfordLhotka replied on Friday, February 06, 2009

I think you just need to implement INotifyPropertyChanged so the change notifications flow up through the object graph, but I'm not entirely sure. You are exploring an area I haven't looked into in any depth.

SmartDate is a value type, and so isn't the same as a reference type, so you may have to dig fairly deep into the field manager implementation to see if it supports what you are trying to do.

RockfordLhotka replied on Friday, February 06, 2009

I just took a quick glance at FieldData<T>, and it doesn't hook or deal with any PropertyChanged event from the value it contains.

You'll probably need to create your own IFieldData<T> object that can act as a smarter container that does hook the event - though I'm not sure the field manager listens for change events off the IFieldData objects (I don't think so) and so even that may be insufficient.

Your easier course of action is probably to make your object an actual child object - have it inherit from BusinessBase<T> so you get all the automatic hookups.

Copyright (c) Marimer LLC