Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
For example i have window
XML
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   x:Class="WpfApplication2.MainWindow"KeyDown="Window1_KeyDown_1">

I creted Event KeyDown="Window1_KeyDown_1".
In this Event i can realize behavior when i press "/" button.
https://msdn.microsoft.com/ru-ru/library/system.windows.input.key%28v=vs.110%29.aspx[^] Tell me please what is code for this key,from Key Enumeration.
Posted
Updated 6-Feb-15 14:07pm
v2
Comments
Inimicos 6-Feb-15 20:00pm    
Also interesting in "=" Key.
[no name] 6-Feb-15 20:38pm    
Sergey Alexandrovich Kryukov 6-Feb-15 23:24pm    
Wrong link, I must say. The question is about WPF.
I answered the question, please see.
—SA
[no name] 7-Feb-15 10:28am    
Embarrassing. Seems I was something absent. Thank you for your note.
Bruno
Sergey Alexandrovich Kryukov 7-Feb-15 10:32am    
You are welcome. Please don't fee embarrassed. :-)
—SA

1 solution

No, you did not create an event. The event is this: https://msdn.microsoft.com/en-us/library/system.windows.uielement.keydown%28v=vs.110%29.aspx[^].

And you, at best, created the event handler and added it to the invocation list of the event instance of some UIElement, Window in your case; and this is what you really need to handle the event. The code sample for the event handler is shown on the MSDN page referenced above.

With this event, you need to use the property KeyEventArgs.Key of the event arguments instance passed to your handler, as shown in the same code sample. And the keys to use are here:
https://msdn.microsoft.com/en-us/library/system.windows.input.key%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2
Comments
Inimicos 7-Feb-15 2:44am    
And so what the code for "/" and "="?.I already made for other button,in the link above.For example Key "1" is Key.Oem1.
Sergey Alexandrovich Kryukov 7-Feb-15 3:18am    
Can you do some work by yourself? '/' is Key.Divide, and so on. Do I have to find them for you? How about doing some experiment to find the all keys? Do you understand that you can write few lines of code for key finding?
—SA
Inimicos 7-Feb-15 3:26am    
I thought you know all))
Sergey Alexandrovich Kryukov 7-Feb-15 10:37am    
I sounds like you don't understand the concepts of "knowledge". Hope you are not going to use your memory as a trash container.
—SA
Inimicos 7-Feb-15 14:31pm    
Yes i don't understand some concepts.But sometimes i don't understandm,but i can use it.I have created calculator with basic buttons already.Thank's for your work,i appreciate it.

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