This project has moved. For the latest updates, please go here.

using farseer with WPF

Topics: User Forum
Sep 17, 2010 at 2:47 PM

Hello,I am trying to get the samples working with WPF using (Farseersimplesamples_v5_56959\Demo1)

I am using the class library version of farseer.

My application cannot find the namespace FarseerPhysics.Mathematics;


is there  a class library version of this, or how can i get round this?


Oct 2, 2010 at 12:44 PM

Maybe i am asking the wrong question.  Maybe Farseer is not for WPF.  

I found this old thread which had some code examples posted which now has dead links:

Has anyone had any small success with WPF, that they may be willing to post a short example of code with WPF and farseer? thanks.

Oct 2, 2010 at 1:21 PM

Farseer Physics Engine 3.0 should work on WPF. At least, it does work here. Could you send me your project? upload it somewhere or contact me using codeplex and I will reply with my email.

Oct 4, 2010 at 12:33 PM
Edited Oct 4, 2010 at 1:01 PM

Thank u very much

if i just got started im sure i'd be fine.  I've just triedstarting again with something even more simple - creating a body.  it doesn't seem to work again.

I'm using farseerphysics3.dll, and trying some stuff in

so ive just pasted in this code to a new project:

            int mass = 1;

            float width = 128;

            float height = 128;

            Body rectBody = new Body();

            rectBody.Mass = mass;

            rectBody.MomentOfInertia = mass * (width * width + height * height) / 12;

            rectBody.Position = new Vector2(100, 200);

The error in this case is pharseerphysics.dynamics.body has no constructors defined.

heres the project file:


.... ah just in case heres the other project i attempted badly:

Oct 7, 2010 at 6:27 AM

ok i've found out that I shouldnt use the dll files, but include the directories. 
also i should have installed xna to understand those examples first, before moving on to wpf.


Oct 10, 2010 at 2:01 AM
Edited Oct 10, 2010 at 2:02 AM

I've got a moving rectangle!! (but gravity does not seem to work)

Using the dispatch timer instead of the storyboard they use in the silverlight examples.  the storyboard didn't work for some reason.

I am having trouble with gravity.  my rectangle moves down now, but does not seem to accelerate. 

The world has been created with gravity though.

Im not sure if i need a gravityController, though i have tried that.


heres my code so far.

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        World _world = new World(new Vector2(0, -20));
        Body _rectBody;
        DebugView _debugView;

        DispatcherTimer dispatcherTimer = new DispatcherTimer();

        public MainWindow()

            // Set up the timer for game updates
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0,0,100);

            // create a body and place it in position defined by Vector2
            _rectBody = BodyFactory.CreateBody(_world,new Vector2(5, 50));

            _rectBody.Mass = 100;
            _rectBody.LinearDamping = 0;
            _rectBody.BodyType = BodyType.Dynamic;
            label1.Content = _world.Gravity.Y;
            _rectBody.IgnoreGravity = false;

        void dispatcherTimer_Tick(object sender, EventArgs e)
            label2.Content = this._rectBody.Position.Y;
            translateTransform.Y = 50 -_rectBody.Position.Y;


My goal firstly is still to get a simple example working with WPF (before starting my proper project).  when i get this done, i will post the code, so hopefully its easier for the next person who tries this.

Any help with gravity would be much appreciated.

Oct 10, 2010 at 4:41 AM

Well, after some days trying to get WPF working, i stumble across and


I was trying to use version 3, and didn't know that version 2 was there with samples!  I had thought that nothing was made for WPF!

Now I know why no one wanted to help, or why Genbox didn't understand what the problem was.


Nov 21, 2010 at 6:47 PM

thanks :) it was very helpfull,

why did the WPF examples didn't make it to version 3?

Nov 21, 2010 at 8:51 PM

If you have ported the WPF samples to FPE 3.1, feel free to submit a patch with the project.