Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
Neither, don't do it. But if you must, Winforms. WPF uses DirectX which messes with XNA. –  William 'MindWorX' Mariager Apr 14 '12 at 5:53
    
What do you mean by Messes with XNA? –  Nips Apr 14 '12 at 6:03
    
I think you mean to ding @William'MindWorX'Mariager. Dinged! –  Jonathan Hobbs Apr 14 '12 at 7:16
    
@William'MindWorX'Mariager, you might have to restore some renderstates, but I haven't even found evidence of that yet. –  Roy T. Apr 14 '12 at 9:21
1  
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 :( –  Aralox Apr 14 '12 at 10:21
show 3 more comments

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 WPF: http://blogs.msdn.com/b/nicgrave/archive/2010/07/25/rendering-with-xna-framework-4-0-inside-of-a-wpf-application.aspx

XNA in Winforms: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1 (official method, preferred)

XNA in Winforms: http://roy-t.nl/index.php/2008/10/09/xna-30-and-winforms-the-easy-way/ (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: http://msmvps.com/blogs/valentin/pages/xnaml-component.aspx but there is also this one which I've seen used in actual games: http://neoforce.codeplex.com/

share|improve this answer
    
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). –  ChocoMan Aug 19 '13 at 17:23
    
Doesn't Mouse.getstate() work? –  Roy T. Aug 19 '13 at 17:25
    
No it didn't work. I will make a question showing what I got. –  ChocoMan Aug 19 '13 at 17:28
    
I've made a question with the classes I'm using gamedev.stackexchange.com/questions/61006/… –  ChocoMan Aug 19 '13 at 18:47
add comment

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.

share|improve this answer
add comment

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.