Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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
Posted
Comments
fvalerin 26-Mar-12 18:32pm    
SA : Im using XP SP3 and a lot of hotfixes, framework 4. I can send you an image of the errors to prove you the error message is directly related to the enumerate element not being part of this enumerate, and you can help me. But I dont know how people can coordinate direct contact with others members and if I can publish my email.

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

[EDIT]
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.

[EDIT]
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
 
Share this answer
 
v3
Comments
Espen Harlinn 27-Mar-12 5:23am    
Good points :-D
Sergey Alexandrovich Kryukov 27-Mar-12 11:50am    
Thank you, Espen.
--SA
VJ Reddy 5-Jun-12 9:45am    
Good points :)
Espen Harlinn 5-Jun-12 9:46am    
Thank you, VJ :-D
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
 
Share this answer
 
Comments
Abhinav S 26-Mar-12 21:49pm    
5!
Espen Harlinn 27-Mar-12 5:23am    
Thank you, Abhinav!
Sergey Alexandrovich Kryukov 26-Mar-12 22:10pm    
My 5. I did not pay attention for differences for Silverlight, so I revised my answer.
But -- I credited your post, and after appropriate fixed I explained it and gave useful recommendations. Please see.
--SA
Espen Harlinn 27-Mar-12 5:24am    
Thank you, Sergey :-D
fvalerin 28-Mar-12 14:17pm    
Thank you guys, both of you had enlighten me. I consulted the member indicated by Espen (PlatformKeyCode) and it works and I've watched what does the keydown event handler and it works.
Any way and after all I think Im going to use the javascript-generated KeyPress event, instead of the delegate on .net, because the keydown or keyup events on .net wont let me to reject a particular key (or I dont know how), in javascript it seems easier.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900