I am using a RichEditBox for a UWP, and have a scenario where I am trying to capture 'delete' key down events. Backspace and other keys work fine, this is specific to delete. For some reason, I have unable to capture 'delete' key down events, but listening to key up works just fine.
Does RichEditBox have some behavior on 'delete' that merits it swallowing the event? Any ideas?
<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
}
Use PreviewKeyDown
& PreviewKeyUp
instead.