0

I have a window which consist 3 user controls. 3rd user control consist a datagrid which filled up when a browse button is clicked and file is open in 1st user control. 2nd user control consist some filter operation controls over datagrid.

What I need is to bind some hotkeys in 3rd user controls. Problem - when I browse a file in 1st user control focus is not set to datagrid so hot keys not worked. If I use any filer operation in 2nd user control than also focus removed from datagrid and keys will not work. What should I do so that when there is file open and any filer operation performed then focus should be on datagrid so that hot key will work?

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
kattui
  • 19
  • 4
  • Attach the current code if you can, it's easier then to give some tailored advice. And have you tried calling `datagrid.Focus()` at the end of each event handler for the 1st and the 2nd user control? Another solution would be attaching the _key pressed_ event handler to the window and not to the datagrid itself. – Mike Dec 21 '18 at 11:09
  • Firstly, User Controls are overkill and 9 times out of 10 are not needed. You can attach Key Bindings in xaml [Here is a SO post](https://stackoverflow.com/a/19702668/2029607) as always use MvvM. Looking at the lack of code I am assuming there is no MvvM. To manage focus use FocusManager [here is another post](https://stackoverflow.com/a/21891179/2029607). Good luck – XAMlMAX Dec 21 '18 at 14:00

0 Answers0