我仔细阅读了以下链接: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.previewkeydown.aspx 和这里: enter link description here 我不是(也不能使用)“System.Windows.Forms”。 我使用“System.Windows.Input”。
我似乎找不到从标准美国键盘捕获箭头键KeyDown或KeyUp事件的位置。
以下是我正在使用的xaml代码示例:
<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>
这是我的.cs代码(没有拿起箭头键):
private void inputBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Up)
{
// do stuff
}
}
我能找到的所有东西总是参考“表格”,找不到任何“输入”