VS2010在System.Windows.Input.Key中找不到逗号键 [英] Can't Find Comma Key in System.Windows.Input.Key with VS2010

查看:81
本文介绍了VS2010在System.Windows.Input.Key中找不到逗号键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好:

1)就像主题说的那样,我使用VS 2010在System.Windows.Input.Key枚举中找不到逗号键(,").我正在使用我的第一个Silverlight 4应用程序(我不知道这是否影响).我也是VS2010的新手.
帮助"表明该枚举中存在"OemComma"项,但是当我要对智能感知(或其任何称为)进行编码时,则不会显示该元素,当然编译器会生成类似的错误.". .element不存在...."

我需要比较此枚举变量中的值是否为,"字符.

范例:

System.Windows.Input.Key Tecla;
if(Tecla == System.Windows.Input.Key.OemComma)......//或类似的东西

这会导致编译器错误:"...元素不存在...."

我该如何解决?或者至少是我需要比较的解决方法?

2)我在命名空间"System.Text"中找不到类"ASCIIEncoding"
在VS 2010中已经不存在了? (因为VS是哪个版本的????)我应该改用什么?

预先谢谢您.

Good morning :

1) Like the subject says I Can''t Find Comma Key (",") in System.Windows.Input.Key enumerate, using VS 2010. I''m working with my first Silverlight 4 application (I dont know if this affects). I''m new to VS2010 too.

The Helps indicates the item "OemComma" exists in this enumerate, but when I''m going to coding the intellisense (or whatever its called) doesn''t show this element, and of course the compiler generates an error like "...element doesn''t exists ...."

I need to compare if the value in a variable of this enumerate is the "," character.

Example :

System.Windows.Input.Key Tecla;
if (Tecla == System.Windows.Input.Key.OemComma) ...... // or something like that

That gives a compiler error : "...element doesn''t exists ...."

How can I resolve this ? Or at least a workaround for the comparison I need ?

2) I can''t find the class "ASCIIEncoding" in the namespace "System.Text"
It doesnt exist anymore en VS 2010 ??? (Since which version of VS ????) What should I use instead ?

Thank you in advance

推荐答案

我确认:System.Windows.Input.Key.OemComma是有效的枚举成员.


正如Espen所指出的,但不是针对Silverlight.抱歉,我无法解释这种la脚的来源.我建议执行以下操作:在Silverlight中编写事件KeyDown的句柄,在调试器中运行它,在客户端上按逗号,然后看看会发生什么. [END EDIT]

错误消息元素不存在"看起来不像是与该问题相关的消息.并且System.Text.ASCIIEncoding是有效的类.至少对于.NET v.3.5及更高版本是正确的.


但不是针对Silverlight. (很抱歉,我之前没有对此进行关注.)我可以解释一下:ASCII不再被视为Web应用程序的合法名称.我建议您使用UTF-8,而不要使用ASCII.可能会导致数据丢失.
[END EDIT]

原则上,"VS 2010中存在"是不正确的.这些库存在于.NET v.3.5中.它与Visual Studio无关. VS 2008支持.NET Framework目标2.0到3.5. (以防万一,请检查正在使用的项目的目标平台.)

—SA
I confirm: System.Windows.Input.Key.OemComma is a valid enumeration member.


But not for Silverlight, as Espen pointed out. Sorry, I cannot explain where such lame comes from. I would recommend to do the following: write a handle of the event KeyDown in Silverlight, run it under debugger, hit comma on the client and see what happens.
[END EDIT]

The error message "element does not exist" does not look like a message related to the problem. And System.Text.ASCIIEncoding is a valid class. At least this is true for .NET v.3.5 and up.


But not for Silverlight. (Sorry I did not pay attention for this before.) I can explain it: ASCII cannot be considered legal for Web applications anymore. I would recommend you using UTF-8, and never ASCII. It can cause loss of data.
[END EDIT]

"Exist in VS 2010" is not right in principle. The libraries exist in .NET v.3.5. It has nothing to do with Visual Studio. VS 2008 supports .NET Framework targets 2.0 to 3.5. (Just in case, check the target platform of the project you are working with.)

—SA


看看:
KeyEventArgs.PlatformKeyCode属性 [ ^ ]-System.Windows.Input.Key的Silverlight版本似乎省略了OemComma值,但是您可以使用此属性来检测逗号-在Windows上,该值为0xBC-您可以在此处查找: Windows虚拟密钥代码 [
Have a look at:
KeyEventArgs.PlatformKeyCode Property[^] - the Silverlight version of the System.Windows.Input.Key seems to omit the OemComma value, but you can use this property to detect a comma - on Windows the value will be 0xBC - you can look it up here: Windows virtual Key codes[^]

Best regards
Espen Harlinn


这篇关于VS2010在System.Windows.Input.Key中找不到逗号键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆