Steps needed to reproduce the issue :
1 Create a project that uses "Physics Helper"
2 Add a PhysicsControllerBehavior to the Canvas Layout
3 Add a rectangle
4 Add 1 PhysicsObjectBehavior to the rectangle
5 Add 2 PhysicsObjectBehavior to the rectangle
6 Run
Result:
When we run the silverlight application we get the folowing error :
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Message: Unhandled Error in Silverlight Application Element is already the child of another element. at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection
1 collection, CValue value)
at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection1 collection, DependencyObject value)
at System.Windows.PresentationFrameworkCollection
1.AddDependencyObject(DependencyObject value)
at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
at System.Windows.PresentationFrameworkCollection1.Add(T value)
at Spritehand.FarseerHelper.PhysicsSprite..ctor(PhysicsSimulator physicsSim, Canvas parentCanvas, UIElement element, List`1 points, Boolean showDebug, Single defaultFriction, UIElement boundaryElement)
at Spritehand.FarseerHelper.PhysicsControllerMain.AddPhysicsBody(PhysicsObjectMain physObject)
at Spritehand.PhysicsBehaviors.PhysicsObjectBehavior.controller_Initialized(Object source)
at Spritehand.FarseerHelper.PhysicsControllerMain.InitializedHandler.Invoke(Object source)
at Spritehand.FarseerHelper.PhysicsControllerMain.InitializeObjects()
at Spritehand.FarseerHelper.PhysicsControllerMain._timerInitialize_Completed(Object sender, EventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Line: 1
Char: 1
Code: 0
URI:
http://localhost:2084/TestPage.html
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------