tags:

views:

61

answers:

1

Hello all,

I develop the part of app functionality. I have the databinding object 'A' and another object 'B'.

public class SomeProxy
{       
    public SomeProxy(BindingSource A)
    {          
        var b = new B(A.SomeProperty);          
    }
}

public class B
{
    public B(List<T> somePropertyFromA)
    {
        SomePropertyFromA = somePropertyFromA;
    }

    public int SomePropertyFromA{get;set;}

    //Some autocalculated propeties, that are based on SomePropertyFromA

    //I want to reculculate them, when the SomePropertyFromA will be changed
}

'B' object culculates some values, based on the property 'a' of the 'A' object. I want to bind property in object 'B' to the same property 'a' in 'A'. It's need to handle on changes of the 'a' property, because some UI controls are binded to 'B'-s properties. How can I do this?

Sorry for some oddness. Thanks

A: 

Do you mean you need a bi-directional link?

Both A and B can have properties that point to each other. Just be sure to create object B -outside- of A, so that you can do dependency injection. Order of things should be:

B objectB = new B();
A objectA = new A(objectB);

Basic rule: do not create objects in constructors.

Hace
Yeap.. I understanded that I can't to specify this question completely clear.
w1z