mpen
mpen

Reputation: 282865

How to use XNA in WPF?

So... I want to make a game, and I want to write it in C#. In the past, I've made a mario clone using C++ and OpenGL. I quite like OpenGL, but I don't know how well it's supported inside C#/WPF. Also, it might be beneficial to use an actual game library? I guess XNA is the game library for C#, so maybe I'll invest a bit of time learning that.

However, I want to use WPF form controls for my level editor... is there any way that I can embed an XNA (DirectX?) window inside a WPF app?

Specifically, I don't need any buttons or things inside the XNA/DirectX widget, just around it, so no mixing required...just need to get a graphics widget in my WPF form.

Upvotes: 7

Views: 10765

Answers (3)

Andrew Russell
Andrew Russell

Reputation: 27215

Nick Gravelyn explains how to do it on his blog.

Although, if it's just for an editor, you may find using WinForms is easier and better supported.

Upvotes: 5

Muad'Dib
Muad'Dib

Reputation: 29216

WPF uses DirectX, and you can do direct "interop" here is a codeProject article on the subject. Here is an article i dug up where the author is using win-forms and WPF controls in an XNA project. Might be worth a look for you.

Upvotes: 2

David Conde
David Conde

Reputation: 4637

First of all, you should ask this on gamedev.stackexchange.com. But I've seen a tutorial embedding XNA.

You should check this question and this page. They are on Windows Forms, but they'll help.

Also check this and this articles.

Keep in mind one thing. XNA is meant to be used for the whole game, integration would be useful on making level editors like you say, but not for a full game.

Upvotes: 2

Related Questions