Adding behavior in code

Jul 23, 2010 at 2:35 AM
Hi I've got this: void c_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // Add behavior PhysicsObjectBehavior objBehav = new PhysicsObjectBehavior(); objBehav.Mass = 2; objBehav.RestitutionCoefficient = 0.6; BehaviorCollection behaviorCollection = Interaction.GetBehaviors((Canvas)sender); behaviorCollection.Add(objBehav); ((Canvas)sender).UpdateLayout(); <-- tried this } However it seems the behavior isn't taking effect. If I move this code into the constructor it does, I'm not sure where the difference is.. I guess something has to be notified ? thanks
Coordinator
Jul 24, 2010 at 11:06 AM
Edited Jul 24, 2010 at 11:08 AM

There is an additional call necessary - check this post - http://www.andybeaulieu.com/Home/tabid/67/EntryID/168/Default.aspx

Also this one - http://physicshelper.codeplex.com/Thread/View.aspx?ThreadId=77450