Add behavior to a Body by code

Feb 18, 2013 at 12:24 PM
I've got this code
            playerBody = BodyFactory.CreateBody(world);

            CircleShape playerShape = new CircleShape(ConvertUnits.ToSimUnits(playerTexture.Width / 2f), 5f);
            
            Fixture playerFixture = playerBody.CreateFixture(playerShape);
            playerBody.BodyType = BodyType.Dynamic;
            playerBody.Position = ConvertUnits.ToSimUnits(new Vector2(viewport.Width / 2f, viewport.Height / 2f));
            playerBody.Restitution = 0.8f;
taken from a tutorial and I'd really like to allow mouse picking on playerBody.

I know how to do it with XAML but I can't do it in C#!

I'm trying with
            PhysicsControllerBehavior pcb = new PhysicsControllerBehavior();
            pcb.MousePickEnabled = true;
            pcb.Attach(playerBody);
but, of course, it won't even compile as the Attach method expects a DependencyObject.

How can I do it?

Thanks