This is a migrated thread and some comments may be shown as answers.

SelectionChanged fires on non-focused item

2 Answers 45 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 13 Feb 2018, 11:52 AM

When I'm opening a RadCombobox, focus an item with the mouse, moving the mouse pointer out of the Combobox and thus loosing the focus, SelectionChanged is fired when I'm pressing the Enter key. I'd expect that no item would be selected in this case since no item is visibly highlighted, but instead an item gets selected (probably the item that was highlighted last by moving the mouse pointer).

Is this behavior intended?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 16 Feb 2018, 09:04 AM
Hi Michael,

This is the default behavior. When Enter key is pressed the last highlighted item is selected. To workaround this behavior you can create custom which derives from RadCombBox. In the custom class, you can override the HandleKeyDown() method. Then you can check if there is highlighted an item and return false if not. 

I have created sample project which demonstrates this approach. The project is attached to this reply. Give it a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Michael
Top achievements
Rank 1
answered on 16 Feb 2018, 11:42 AM

Hi Dinko,

works perfect!

Instead of deriving a class from RadComboBox I've decided to handle the PreviewKeyDown-event in the way you've described.

Thanks

Michael

 

Tags
ComboBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Michael
Top achievements
Rank 1
Share this question
or