无法访问System.Windows.Input下的Keyboard类

时间:2013-08-05 19:06:14

标签: c#

我正在开发一个简单的控制台应用程序,它只是在屏幕上显示内容。

我遇到了System.Windows.Input类的问题,我只是无法找到它们。

这里是我尝试的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace FUAndLOLInstall.LookForAndActivateFile
{
    class KeyboardHandler
    {
        public void usKeyboard()
        {
            System.Windows.Input.Keyboard //its like the class Keyboard not exsit.
        }
    }
}

一些信息: 我使用librery TestStack.White在windowm上做一些minpultion,我从我的应用程序开始。

TestStack.White本身有一个Keyboard类(White.Core.InputDevices.Keyboard),但是这个类可能会阻止我去学习System.Windows.Input.Keyboard类吗?

1 个答案:

答案 0 :(得分:11)

由于这是一个控制台应用程序,因此您需要添加对PresentationCore.dll的引用。默认情况下,控制台应用程序中不会引用此程序集。

您可以在Keyboard的文档中看到这一点:

  

命名空间:System.Windows.Input

     

程序集:PresentationCore(在PresentationCore.dll中)

这是主要的WPF程序集之一,默认包含在WPF项目中,但不包括在控制台应用程序中。