True, this is strange. This is clearly a focus problem, but I cannot understand why the grid does not accept focus, even when we click on it.
Although there is a workaround: create a handler for the loaded grid event:
<Grid x:Name="theGrid" KeyDown="Grid_KeyDown_1" Focusable="True" Loaded="TheGrid_OnLoaded">
And then fix the focus in the code:
private void TheGrid_OnLoaded(object sender, RoutedEventArgs e) { theGrid.Focus(); }
After that, your key event will work. Hope this helps.
source share