How to use XNA in WPF?

So ... I want to create a game, and I want to write it in C #. I used to make a mario clone using C ++ and OpenGL. I really like OpenGL, but I don’t know how well it is supported inside C # / WPF. In addition, it may be useful to use a real library of games? I guess XNA is a game library for C #, so maybe I will spend a little time learning this.

However, I want to use WPF controls for my level editor ... is there a way in which I can embed an XNA window (DirectX?) Inside a WPF application?

In particular, I don’t need any buttons or things inside the XNA / DirectX widget, just around it, so no mixing is required ... just need to get a graphical widget in my WPF form.

+7
c # wpf xna
source share
3 answers

Nick Gravelin explains how to do this on his blog.

Although, if it's just for the editor, you can find with WinForms easier and better support.

+6
source share

WPF uses DirectX, and you can do a direct "interop" here is the project code article on this. Here is an article I dug up when the author uses win-forms and WPF controls in an XNA project. Maybe you should take a look.

+2
source share

First of all, you should ask about it at gamedev.stackexchange.com. But I saw a tutorial embedding XNA.

You should check this question and this page. They are in Windows Forms, but they will help.

Also check out this and these articles.

Keep in mind one thing. XNA is supposed to be used for the whole game, the integration will be useful for creating level editors, as you say, but not for a full game.

+1
source share

All Articles