If you compare integration between WPF with XNA vs Winforms with XNA, what is the most suitable framework to integrate XNA framework with.

  • \$\begingroup\$ Neither, don't do it. But if you must, Winforms. WPF uses DirectX which messes with XNA. \$\endgroup\$
    – William
    Commented Apr 14, 2012 at 5:53
  • \$\begingroup\$ What do you mean by Messes with XNA? \$\endgroup\$
    – Nipuna
    Commented Apr 14, 2012 at 6:03
  • \$\begingroup\$ I think you mean to ding @William'MindWorX'Mariager. Dinged! \$\endgroup\$ Commented Apr 14, 2012 at 7:16
  • \$\begingroup\$ @William'MindWorX'Mariager, you might have to restore some renderstates, but I haven't even found evidence of that yet. \$\endgroup\$
    – Roy T.
    Commented Apr 14, 2012 at 9:21
  • 1
    \$\begingroup\$ Yeah that's true, and its fine if your controls are static, but for moving controls like healthbars, there will be flickers as they move across your XNA container. I haven't personally used XNA with Winforms, but I used a different renderer (Mogre) could render both with DirectX and OpenGL, and I experienced this problem with both :( \$\endgroup\$
    – Aralox
    Commented Apr 14, 2012 at 10:21

3 Answers 3


Both approaches are valid, but require a bit of thinkering. Using Winforms or WPF in XNA can work great and is great for level editors, but it's usually not that polished that you can ship it to customers, so only use it for your internal tools.


XNA in Winforms (official method, preferred)

XNA in Winforms (quick but hacky method read the notes at the end!)

Another method, that you can ship to customers is to use one of the many GUI libraries for XNA. I've looked around a bit and this seems the most complete, but there is also this one which I've seen used in actual games: NeoforceControls

  • \$\begingroup\$ I have a winform with a custom XNA panel in it and having problems getting mouse input to work. Keyboard works and updates fine, but nobody is saying no real solution as to how to get the mouse to interact with the custom panel (as in yawing and pitching or just to check to see if the mouse is responding). \$\endgroup\$
    – ChocoMan
    Commented Aug 19, 2013 at 17:23
  • \$\begingroup\$ Doesn't Mouse.getstate() work? \$\endgroup\$
    – Roy T.
    Commented Aug 19, 2013 at 17:25
  • \$\begingroup\$ No it didn't work. I will make a question showing what I got. \$\endgroup\$
    – ChocoMan
    Commented Aug 19, 2013 at 17:28
  • \$\begingroup\$ I've made a question with the classes I'm using gamedev.stackexchange.com/questions/61006/… \$\endgroup\$
    – ChocoMan
    Commented Aug 19, 2013 at 18:47

Most people seem to prefer WinForms due to reduced hassle it takes to make XNA and WPF work together, which for the most part is fine. However, more and more people are doing their best to make WPF a good choice with the help of components and libraries that enable the ability to Render XNA inside an area or control portion of the screen. I helped develop the one I'm posting here and I think it's a fairly lightweight, simple solution for having XNA in WPF. However, just building a good UI system in XNA itself will make your product more shippable.

In either case, I'll leave this here: https://xnaml.codeplex.com/


This is a "which is better" question, and it depends entirely on your needs.

That being said I have done this previously using WinForms, I decided to use WinForms because the approach seemed to be simpler and require less setup. WinForms Graphics Sample is a link to an App Hub posting which includes the relevant source code to get started. Be warned though, mixing XNA calls and GDI calls causes severe flickering and is impractical. To overcome this limitation I drew basic shapes with another App Hub code sample: Primitive Batch.


Not the answer you're looking for? Browse other questions tagged .