I’m creating a usercontrol for editing an address class. The address class implements Inotifypropertychanged and has properties such as street, zip, code etc.
Then I have a customer class that holds an address class.
I want to create a usercontrol for editing address such that I bind the addresscontrol to the customer’s address property. The address property should then be updated when I change the address in the user control.
<UIComponents:AddressControl Address="{Binding Address, Mode=TwoWay}"/>
Address is a dependency property.
The property on the customer class also implements inotifypropertychanged, but the set is never called. I suspect that this is because the actual object isn’t changed just a subproperty.
So how do I get it to call the setter when the object changes?
Regards
Morten
Inside your Customer class, hook the Address object’s PropertyChanged event to a handler we’ll call ReflectPropertyChanged. ReflectPropertyChanged will call NotifyPropertyChanged on your Address member.
If you do this don’t forget to implement a PropertyChanged handler in your Address dependency property that removes the handler from the old value when a new Address is set.