tags:

views:

380

answers:

2

I have a C# ComboBox using WPF. I have code that executes when the combobox's gotfocus is activated. The issue is that the gotfocus event is executed every time a selection is made from the combobox. For example, the gotfocus is executed when you first click on the combobox and then when you make a selection even though you have not click on any other control. How do you code it so the gotfocus event is only executed when it actually receives the focus?

A: 

I'm not too hot on WPF; but if you're trying to detect changes to the list (click on new value etc) you can use SelectedIndexChanged events..

On the other hand, if you really do want to know simply when the control is focussed, can you filter it by saying something like;

if (combo1.Focused && combo1.SelectedIndex == -1)
{
     ...
}

.. ? It really depends on what youre trying to detect, exactly.

pierre
A: 

Good info in this other question.

http://stackoverflow.com/questions/830510/issue-with-wpf-focus link

Mikeb