B
B
BadCats2017-06-21 21:34:08
WPF
BadCats, 2017-06-21 21:34:08

ComboBoxMenu_SelectionChanged - standard implementation?

on msdn, this is the standard implementation for the SelectionChanged handler:

ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);

- I get a NullReferenceException. Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2017-06-21
@BadCats

You will be defined at you ListBox or ComboBox.
In the header of the ComboBox, so when the event is fired, you have a sender of type ComboBox, not the ListBox you are casting to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question