PropertyChanged Help NeededPropertyChanged Help Needed
Old forum URL: forums.lhotka.net/forums/t/1879.aspx
cash_pat posted on Friday, December 01, 2006
Hi,
I have a BO containining another BO (not a collection) as child. PropertyChanged event from the Child BO is not reaching the parent.
I have read all posts regarding PropertyChanged but could not find anything. Is this a bug?
regards
cash pat
ajj3085 replied on Friday, December 01, 2006
When your parent creates the reference to the child, you need to manually hook an eventhandler onto the child's propertyChanged event.
public sealed class Root : BusinessBase<Root> {
public Child MyChild {
get { return myChild; }
private set {
if ( myChild != value ) {
if ( myChild != null ) {
myChild.PropertyChanged -= new PropertyChangedEventHandler( MyChild_PropertyChanged );
}
myChild = value;
if ( myChild != null ) {
myChild.PropertyChanged += new PropertyChangedEventHandler( MyChild_PropertyChanged );
}
}
}
private void MyChild_PropertyChanged( object Sender, PropertyChangedEventArgs e ) {
PropertyHasChanged( "MyChild" );
}
}
Copyright (c) Marimer LLC