将 WPF Windows 添加到 XNA 游戏项目
我正在创建一个实验性游戏(最终将成为游戏的地图编辑器),并且我想在同一项目中包含一个 WPF 窗口,该窗口将与游戏逻辑进行通信。这不是另一个 render-xna-game-in-wpf-window 问题,我读过很多这样的问题,我想生成一个独立于 XNA 游戏窗口的单独的 WPF 窗口,但在同一个程序中,在同一个项目中。当我单击“添加项目”并选择“WPF”时,它给我的只是一个“用户控件”选项,没有窗口或任何其他选项等。我尝试引用PresentationCore,但也没有锁定,我是否遗漏了一些东西?我对互操作性不太了解,所以如果我的尝试很愚蠢,请原谅我。我也不想要“hacky”解决方案(例如创建一个窗口和一个无边界控件并将它们的位置设置相同等),如果它不能完成,只是告诉它,但我确信有一个相对“干净”的解决方案因为它们是完全独立的,所以可以将其视为一个非常简单的 MVC:M 游戏逻辑、V XNA 窗口、C WPF 窗口。并且不要向我提供表单,我知道如何使用表单,但我想要 WPF,我只是更轻松地使用 WPF/XAML 和 WPF 样式控件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
能否从“添加项”菜单添加窗口是由 Visual Studio 项目类型 GUID 控制的。您是否尝试过手动创建窗口 xaml 和 cs 文件(或在另一个测试解决方案中创建并添加现有文件)?或者只是在代码中创建一个 Window 实例并显示它?另外,Window位于PresentationFramework中,而不是PresentationCore中。
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.