WP7 - hide keyboard on enter press in autocomplete box - silverlight

I'm using an autocomplete box and I'd like to remove the focus from the autocomplete box when I press enter on the keyboard.
I tried using the OnKeyDown method but it won't detect the enter key being pressed (it detects all other keys).
How can I detect the user pressing the enter key?
Thanks!

Fortunately I solved it! (I feel a bit stupid for asking the question now).
Turns out that although OnKeyDown works for most controls, in order to detect the enter key being pressed when using an autocomplete control, you need to use OnKeyUp.

Related

MudBlazor MudForm POST on Enter

I'm looking for a way to post a MudForm upon pressing Enter from any control inside the form, without checking each keyboardevent argument and filtering for Enter, and without binding the listener to each form control in every MudForm.
The goal is to post any MudForm across my project by pressing Enter as a default behavior.

How to set focus on textbox and button simultaneously in WinForm

I want to set focus on a button while caret is present in textbox and user can still enter data to textbox. But when user presses enter key, button press will be simulated.
I am currently using a work around to solve this problem by handling onKeyDown event and checking for enter key. But problem is there is no clue for user to understand this as there is not blue border around the button that indicates focus on button.
Here is a example of what I want to implement (user can enter text in textbox while focus is on :
I have tried to search on google and StackOverflow but could not find any relevant result.
This is a fundamental Windows principle. It's not possible to have 2 controls (windows) focused at the same time.
So the focus should be inside the text box. But you can get the visual indication needed by setting the ok button as AcceptButton of the form (you might also want to set cancel button as CancelButton).
In the form constructor, load event or using designer:
this.AcceptButton = okButton;
There is no need to handle KeyDown event - as soon as the text box is not multiline, pressing Enter while the focus is inside it will generate ok button click. The same applies for the button set as CancelButton when you press ESC.

WPF hot keys similar to xamribbon alt keys

Hi I am having a wpf application. I need to show some hot keys to user when they press alt key. The hotkeys must be displayed untill any keydown or click happens. this is similar to XamRibbon alt key I guess this is the same functionality in Excel using alt key.
I could implement by using InputBindings and KeyDown and KeyUp events but my business need is to let it display till user clicks somewhere else or some selection happens or some typing happens. which is the same in XamRibbon and Excel.
How do we achieve this kind of behavior??

Re-open the DropDown of an AutoCompleteBox in Silverlight when a user presses Enter

If a user types a few characters into an AutoCompleteBox, the DropDown is displayed as expected.
If the user then clicks elsewhere on the page, this removes the focus from the AutoCompleteBox, and the DropDown disappears... also as expected.
However, if a user then returns focus to the AutoCompleteBox, and wants to redisplay the DropDown, filtering on the characters already there, the instinct seems to be to press the Enter key to re-filter/re-display the results. This, however, does not happen.
I've managed to capture the Enter key event (must use KeyUp instead of KeyDown), but I'm not sure how to make the DropDown re-appear at that point. Ideas?
Just assign true to the IsDropDownOpen property:-
myACB.IsDropDownOpen = true;

Should the Enter key always trigger the default button, no matter which child control has the focus

I have a form with a default OK button, and a Cancel button. I have a treeview with nodes that can be edited, i.e. you can double-click them or press F2 to open another form.
Now, I've never liked that F2 shortcut, and now that I'm enabling treeview label edition, it's even worse. My first reaction when testing the form was to press "Enter" to edit the selected node, but doing this would go against the normal default button behavior.
Your opinion: Should an application always enforce the default button being triggered with the Enter key? If so what kind of shortcut should an application use to "edit the selected item"?
Definitely not... Confuses our users no end that enter doesn't select what they have highlighted.
Absolutely no. The Enter key is often used to fire the default button but equally often not. For example, Enter generally means new line in a multiline textbox.
Enter sounds like a good bet in this scenario. F2 tends to mean "Edit" in Windows.
However, if this is a long-standing application you may just irritate users who are used to F2.

Resources