-
July 17th, 2013, 11:57 PM
#1
Arrow keys(left,right) down is not captured from PreviewKeyDown event within WPF
Hi,
I was just trying to capture left arrow and right arrow key movement over the text in wpf textbox. I implemented a wpf attached behaviour for the textbox and bound PreviewKeyDown event.
Although, it's capturing all other keys(including Enter,backspace, shift) but it's not capturing the arrow keys.
Can anyone tell me why it's like that?
Thanks in advance.
Below is the function where I am binding it..
private static void OnHandleKeysUp(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
if (d is UIElement)
{
UIElement element = d as UIElement;
if (element != null)
{
if ((bool)e.NewValue)
{
element.PreviewKeyDown -= OnPreviewKeysDown;
element.PreviewKeyDown += OnPreviewKeysDown;
element.KeyUp -= OnKeysUp;
element.KeyUp += OnKeysUp;
element.GotFocus-= OnGotFocus;
element.GotFocus+= OnGotFocus;
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|