c# - Sharing KeyHandlers from MainWindow with a UserControl -
i have usercontrol has few previewkeydown event listeners, move these listeners mainwindow work not when usercontrol active focus, there way achieve this?
the reason have them in usercontrol action of previewkeydown event depends on tabitem selected in usercontrol.
you can handle previewkeydown @ mainwindow level , keydown , usercontrol level. best handle preview events @ container level grid/stackpanel etc. because @ window level many preview events reached various controls.
<window x:class="wpfusercontrol.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:uc="clr-namespace:wpfusercontrol" title="mainwindow" height="605.263" width="701.316" previewkeydown="window_previewkeydown"> <grid> <grid.rowdefinitions> <rowdefinition height="103*"/> <rowdefinition height="217*"/> </grid.rowdefinitions> <uc:usercontrol1 background="aqua"/> </grid> </window>
Comments
Post a Comment