Search code examples
wpfvisual-studio-2010interopxnaxna-4.0

Adding WPF Windows to an XNA Game Project


I'm creating an experimental game (which would eventually become a map editor for a game) and I'd like to include a WPF window in the same project which would communicate with the game logic. This is not another render-xna-game-in-wpf-window question, I've read tons of those, I want to spawn a seperate WPF window independent from the XNA game window, but in the same program, in the same project. When I click Add Item and select WPF, all it gives me as an option is a User Control, no window or any other options etc. I've tried referencing PresentationCore but no lock either, am I missing something? I am not super with interoperability, so forgive me if what I tried is stupid. I also don't want "hacky" solutions (like creating a window and a borderless control and setting their location same etc) if it can't be done just tell it so, but I'm sure there is a relatively "clean" way of doing it since they'll be completely seperate, think of it like a very simple MVC: M Game Logic, V XNA Window, C WPF Window. And don't offer me Forms, I know how to go with forms, but I want WPF, I just work with WPF/XAML and WPF style controls more easily.


Solution

  • Being able to add a Window from the Add Item menu is controlled by a Visual Studio project type GUID. Have you tried to create the window xaml and cs files manually (or create it in another, test solution and Add Existing file)? Or just create a Window instance in code and show that? Also, Window is in PresentationFramework, not PresentationCore.