How to capture the event when WPF combobox item is click, or selected by Enter key?

I had tried this for few hours, but it's not working.

I have a combobox, with a few items in there, generated dynamically like a search box.

Now I want to capture an event, when user click on the dropdown menu item, or click on the dropdown menu item.

How to achieve this? I tried to set mouse/keyboard event handler on Combobox, but it only works on the combobox's textbox, not in the dropdown list.

Thanks.

Edit: I forgot to mention that I has custom DataTemplate on my Combobox. I tried another approach which set the event in ComboBox.ItemContainerStyle.

I tried PreviewKeyDown, but it is not captured. Any idea?

6
задан VHanded 14 April 2011 в 07:06
поделиться