Reputation: 6378
I am using WPF and VB.Net as Coding Language.
When I press any keys, on some keys like all alphabetical keys keyDown Event Fires nicely, But If I use arrow keys then keyDown event Does not Fire. On WPF I don't know how to do it. There was same problem in winForms too. But there was KeyPress event which worked perfectly.
I have searched on google but every where I got the same answer.
this.KeyPreview = True;
But I am using VB.Net. I cant find any this
object in VB.Net
Upvotes: 2
Views: 3824
Reputation: 4770
Maybe the problem is that some inner control in the visual tree capture the event when the arrows key are pressed. In this case you should listen the handled events to. The code below solve it, but it is in C#, you should adapt it:
visualObjetToCaptureKey.AddHandler(Keyboard.KeyDownEvent,
new KeyEventHandler((sender,e)=>{
//event handler
}),
true);
In the event handler you should put what you want to execute. Also you can set a method to handle the event. Hope it works...
Upvotes: 2