0

I've read carefully the following links: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.previewkeydown.aspx and here: enter link description here I am NOT (and cannot use) "System.Windows.Forms". I AM using "System.Windows.Input".

I can't seem to find where I can capture the arrow key KeyDown or KeyUp events from a standard USA keyboard.

Here's an example of the xaml code I'm using:

<ContentControl Width="800"
        Height="30"
        x:Name="cc_InputBox"
        Canvas.Left="10"
        Canvas.Top="698"
        Style="{StaticResource DesignerItemStyle}">
<Grid>
    <Border IsHitTestVisible="False" Background="Gray" />
    <Border Margin="0,0,10,0">
        <TextBox
            x:Name="inputBox"
            KeyDown="inputBox_KeyDown"
            TextWrapping="Wrap"
            Focusable="True"
        />
    </Border>
</Grid>

And here's my .cs code (that's not picking up arrow keys):

private void inputBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
    if (e.Key == Key.Up)
    {
        // do stuff
    }
}

All the stuff I can find is always in reference to "Forms" and can't find anything with "Input"

Community
  • 1
  • 1
Zyre
  • 149
  • 1
  • 11
  • Use `PreviewKeyUp` http://stackoverflow.com/a/3611689/1218281 – Cyral Nov 28 '15 at 03:31
  • Thanks. That link clarified it best. So instead of using "KeyDown="inputBox_KeyDown" in my xaml TextBox control, I used "PreviewKeyDown="inputBox_KeyDown". Quite an easy fix. – Zyre Nov 28 '15 at 03:53

0 Answers0