Paul Knopf
Paul Knopf

Reputation: 9776

WPF Prevent button from taking focus from any other control

I have an "On screen keypad" with some up/down/left/right/select buttons.

The select button is effectively a click and the arrow keys fire the associated up/down/left/right key.

The problem is that when selecting a combo box, I can't press the down/up buttons to navigate the items in the list. It is because the combo box auto closes when loosing focus. I can see similar problems happening with other controls, so I would like to see if there is a way to do the following.

For certain buttons (up/down/etc), when clicked, fire the click event, but don't take focus from w/e currently has the focus. This would allow the combox dropdown to stay open while pressing up/down to navigate through the items.

I have tried to set Focusable=False on the navigation buttons but the focus is still taken away from the combo box and the dropdown closes.

Any ideas/suggestions?

Thanks in advance

Upvotes: 0

Views: 920

Answers (1)

John Bowen
John Bowen

Reputation: 24453

This isn't happening because of anything your Buttons are doing so changing their focus state won't make any difference. ComboBoxes close when you click anywhere outside of them, including empty space, non-interactive controls, other windows...

Upvotes: 1

Related Questions