Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, September 20, 2010 6:57 PM
Hi, I have a test C# application that needs to use KeyBoard.IsKeyDown() method. This method is in System.Windows.Input namespace. I couldn't find out that namespce. How to load this namespace to my project in order to use the method? Thanks!
All replies (5)
Tuesday, September 21, 2010 10:30 AM âś…Answered
That's because System.Windows.Input.Key is on WindowsBase, not PresentationCore.
Paulo Morgado
Monday, September 20, 2010 8:04 PM
System.Windows.Input namespace is only loaded in a WPF project and not any WF (Windows Form) project. It is loaded by default in WPF.
Ali Hamdar (alihamdar.com)
Monday, September 20, 2010 8:28 PM
Namespaces aren't loaded. Assemblies are loaded.
Namespaces are a logical organization of types and assemblies are a phisical organisations of types. Assemblies are deployment units.
Paulo Morgado
Tuesday, September 21, 2010 1:15 AM
Hi,
I think I have learned that the system.windows.input is a part of presentationcore assembly. Once I add a reference for presentationcore, I have the system.windows.input added. My problem is I couldn't get the keyboard.iskeydown()method working. Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
bool IsKeyPress = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Return);
}
}
}
It keeps saying "key is not a type or namespace when I use here. I couldn't even find the key as a member of input. But this code is from the C# help file. I am sure I must have some thing wrong, but I really don'y know what it is. Can anyone point it out for me? Thanks!
Gene.
Tuesday, September 21, 2010 11:43 AM
http://msdn.microsoft.com/en-us/library/system.windows.input.aspxMark Post As Answer If It Helped You and Also Take Some Time Out To Mark The Thread Resolved.