如何在非 UWP C# 项目中访问 Windows.Gaming.Input? [英] How Do I Access Windows.Gaming.Input in a Non-UWP C# Project?
本文介绍了如何在非 UWP C# 项目中访问 Windows.Gaming.Input?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到一些在 C++ 控制台应用程序中使用 Windows.Gaming.Input 的示例,但是否也可以在非 UWP C# 项目中访问它?
I've seen some examples of using Windows.Gaming.Input in C++ console apps but is there a way to access it in a non-UWP C# project as well?
谢谢,
推荐答案
我通过执行以下操作成功做到了这一点:
I've managed to do this by doing the following:
- 确保 VisualStudio 没有运行.
- 在文本编辑器中打开您的项目
*.csproj
文件,例如记事本. - 将
添加到10.0 *.csproj
文件.您可以将其放在
条目之后. - 在 Visual Studio 中打开您的项目.
- 使用 nuget 添加
System.Runtime.WindowsRuntime
参考(我使用的是当时最新的稳定版本 v4.7.0),或手动浏览系统上的 DLL 文件. - 在解决方案/项目资源管理器中,右键单击引用 ->添加引用...
- 您应该能够看到Universal Windows"现在作为一种选择.
- 添加
Windows.Gaming
引用. - 在您的
*.cs
文件中,您将希望使用带有using Windows.Gaming.Input;
的参考.如果未找到引用,请尝试将其包含在命名空间之外.
- Make sure VisualStudio is not running.
- Open your project
*.csproj
file in a text editor, e.g. notepad. - Add
<TargetPlatformVersion>10.0</TargetPlatformVersion>
to the*.csproj
file. You can put it after the<TargetFrameworkVersion/>
entry. - Open you project in Visual Studio.
- Add the
System.Runtime.WindowsRuntime
reference (I used v4.7.0, newest stable version at the time) with nuget, or manually browse for the DLL file on your system. - In Solution/Project Explorer, right-click References -> Add Reference...
- You should be able to see "Universal Windows" on the side as an option now.
- Add the
Windows.Gaming
reference. - In your
*.cs
files, you'll want to use the reference withusing Windows.Gaming.Input;
. If the reference is not found, try including it outside the namespace.
这篇关于如何在非 UWP C# 项目中访问 Windows.Gaming.Input?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文