RichEditBox - KeyDown 不捕获 'delete' 键,但 keyup 可以
RichEditBox - KeyDown doesn't capture 'delete' key, but keyup does
我正在为 UWP 使用 RichEditBox,并且有一个场景,我试图捕获 'delete' 按键事件。退格键和其他键工作正常,这是特定于删除的。出于某种原因,我无法捕获 'delete' 按键事件,但听按键工作正常。
RichEditBox 在 'delete' 上是否有一些值得它吞噬事件的行为?有什么想法吗?
<RichEditBox x:Name="Content"
AcceptsReturn="False"
KeyDown="Content_KeyDown"
KeyUp="Content_KeyUp"
SelectionChanged="Content_SelectionChanged"
FontSize="18"
Style="{StaticResource TitleEditBoxStyle}"/>
private void Content_KeyDown(object sender, KeyRoutedEventArgs e)
{
// no breakpoint hit, cannot capture delete
switch (e.Key)
{
case Windows.System.VirtualKey.Delete:
{
...
break;
}
}
...
private void Content_KeyUp(object sender, KeyRoutedEventArgs e)
{
// breakpoint hit, key is correct
}
改用 PreviewKeyDown
& PreviewKeyUp
。
我正在为 UWP 使用 RichEditBox,并且有一个场景,我试图捕获 'delete' 按键事件。退格键和其他键工作正常,这是特定于删除的。出于某种原因,我无法捕获 'delete' 按键事件,但听按键工作正常。
RichEditBox 在 'delete' 上是否有一些值得它吞噬事件的行为?有什么想法吗?
<RichEditBox x:Name="Content"
AcceptsReturn="False"
KeyDown="Content_KeyDown"
KeyUp="Content_KeyUp"
SelectionChanged="Content_SelectionChanged"
FontSize="18"
Style="{StaticResource TitleEditBoxStyle}"/>
private void Content_KeyDown(object sender, KeyRoutedEventArgs e)
{
// no breakpoint hit, cannot capture delete
switch (e.Key)
{
case Windows.System.VirtualKey.Delete:
{
...
break;
}
}
...
private void Content_KeyUp(object sender, KeyRoutedEventArgs e)
{
// breakpoint hit, key is correct
}
改用 PreviewKeyDown
& PreviewKeyUp
。