Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1080
KeyUp and PreviewKeyUp events not fired in TextEditorTool
posted

I'm developing an application with a ribbon bar. One of the tools in the ribbon is a search text field (a TextEditorTool object). Next to the the search field there is a search button. Below the ribbon there is a xamDataGrid.
So the idea is that you can filter the data in the grid by entering a string into the TextEditorTool and the press the search button. My customer thought that that instead of pressing the search key it would be more convenient just to press the enter key.

Nothing simpler than that! I just implemented the PreviewKeyUp Event of the TextEditorTool and tested e.Key against Key.Enter. Unfortunately it just doesn't work. I tried lots of potential workarounds but could not make it work.

What could be the problem?

Best Regards

Markus

P.S. I've attached a sample application that illustrates the problem.

VSS2XGUI_TEST.zip
  • 1080
    Verified Answer
    Offline posted

    Thanks to the Infragistics Support (Case CAS-56102-Q2G4P5) my problem is now solved.   I had to set up a Command and to set the textbox input bindings to the enter key.

    Attached you find the example program I've got from Matt (Infragistics Support).

    Hope this helps other people to solve similar problems.

    Markus

     

     

    WpfApplication36.zip
  • 54937
    Offline posted

    The editors exit edit mode when the enter key is pressed. When the editor exits edit mode focus is shifted out of the ribbon and back to the main body of the window. Since keyboard focus is not in the editor when the enter key is released it will not receive a key up. If you wanted to implement something like this you would likely need to handle the PreviewKeyDown for the editor and set e.Handled to true when e.Key == Key.Enter. If in the KeyUp you are done with the editor and want to restore focus to the main body of the window then you would call Keyboard.Focus(null).

  • 280
    Offline posted

    I can confirm this. I also tried fetching the Key.Enter in surrounding Controls, like RibbonTabItem and RibbonGroup. The Key.Enter never reaches those events and i see no option to "enable" the TextEditorTool to recognize the Key.Enter.

    The only way to get around this seems to use a standard TextBox for this purpose. I use this also for a way to let the user enter a Search Term and hit the enter key in order to not click a button with the mouse.