Thursday, 15 March 2012

c# - How to bind two properties of two classes together -



c# - How to bind two properties of two classes together -

first of apologize if question explicit, i'm confused way best , googled can't find solution.

i have class this:

public abstract class auto { public point3d location { get; set; } }

and class this:

class motion { public point3d location {get; set;} public motion(point3d location) { location = location; } }

i want motion.location updated when car.location changed. done until car.location don't renewed.

car1.location=new point3d();

after 2 properties separated. can guarantee motion.location car.location

all declare event @ object level notified when property changes. you'd have add together backend property location can fire event.

public abstract class auto { private point3d _loc; public event system.eventhandler locationchanged; public point3d location { get{ homecoming _loc; } set; { _loc = value; if ( locationchanged != null ) { locationchanged( this, new eventargs() ); } } } }

c# properties bind

No comments:

Post a Comment