Add Handler to Dynamically Added ComboBox WPF

I have added a couple dynamic ComboBox controls.  I want to add a handler to each of them for the SelectionChanged event.  However, intellisense tells me 'no way, José' to the following line:

 cbScore.AddHandler(cbScore.SelectionChanged += new EventHandler(cbScore_SelectionChanged);

Open in new window

All I want to do is add a handler so that if the selection is not -1 the background is white.

I already have a method that colors them red if they have no selection:

for (int i = 0; i < zone1; i++)

    if (((LogicalTreeHelper.FindLogicalNode(gridQuestion, "cbScoreSep" + i) as ComboBox).SelectedIndex) == -1)
        (LogicalTreeHelper.FindLogicalNode(gridQuestion, "cbScoreSep" + i) as ComboBox).Background = new SolidColorBrush(Colors.Red);

Open in new window

Maybe my syntax is wrong.  I am trying to make the move to C# from VB.  Still a bit lost.

Thanks for any help on this.
G ScottAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cbScore.AddHandler(cbScore.SelectionChanged += new EventHandler(cbScore_SelectionChanged);
the syntax is wrong. you have two opening parantheses but only one closing. the += operation is invalid also.

are you working in c++ or c#?

samples for both you find at


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.