wpf - Shortcut keys not working after messagebox is shown -


i have window keybindings in inputbindings defined. work first time , when set focus on control on form.

but when messagbox shown , press "ok" shortcut keys don't work until set focus on control in window.

my inputbindings:

<window.inputbindings>     <keybinding gesture="ctrl+n" command="{x:static local:mainwindow.newmenucommand}" />     <keybinding gesture="ctrl+o" command="{x:static local:mainwindow.openmenucommand}" />     <keybinding gesture="ctrl+s" command="{x:static local:mainwindow.savemenucommand}" />     <keybinding gesture="ctrl+q" command="{x:static local:mainwindow.closemenucommand}" /> </window.inputbindings> 

my commandbindings:

<window.commandbindings>     <commandbinding command="{x:static local:mainwindow.newmenucommand}" executed="newentity" />     <commandbinding command="{x:static local:mainwindow.openmenucommand}" executed="openentity" />     <commandbinding command="{x:static local:mainwindow.savemenucommand}" executed="saveentity" />     <commandbinding command="{x:static local:mainwindow.closemenucommand}" executed="closeentity" /> </window.commandbindings> 

i faced issue while ago, has focus of window found 1 hack resolve -

<window x:class="wpfapplication1.window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     activated="handlewindowactivated"     title="window1" height="300" width="300"> 

and in code behind put focus on window -

private void handlewindowactivated(object sender, eventargs e) {     this.focus(); }  

Comments