Skip to content

KeyDown event does not occur when applying Style. #3165

Closed Answered by nicolaihenriksen
Hoeung asked this question in Q&A
Discussion options

You must be logged in to vote

@Hoeung I suspect the reason you are not able to hit the KeyDown (or PreviewKeyDown for that matter) event handler is because the ListBox does not have focus; even after using the mouse to toggle an item.

I believe that is because the toggle style uses a PreviewMouseLeftButtonDown event to capture the mouse click (see ListBoxAssist.cs) and manually perform the toggle action. This also marks the event as handled which means the ListBoxItem probably never receives an actual MouseDown event which would cause the ListBox (or ListBoxItem) to be focused; this is what happens for a "normal" ListBox.

One solution to this, which unfortunately requires a fix in MDIX, would be to add a call to listB…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Hoeung
Comment options

@Keboo
Comment options

Answer selected by Hoeung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants