I am trying to do a
codebox.ItemsSource = codesList;
codebox.PopulateComplete();
from the Populating event I have created and I get the error
“The name ‘codebox’ does not exist in the current context’
This was working when I just populated it from the MainWindow. Anyone know what I am missing?
Thanks!
This looks like it’s because
codeboxis not visible from the scope of where yourPopulatingevent handler is declared. When thePopulatingevent handler is withinMainWindow, thecodeboxcontrol is “visible” to that code. See here for more info.Where is your
Populatingevent handler declared?Also, note that the
senderparameter in thePopulatingevent should be a reference tocodebox. You could simply cast this to anAutoCompleteBox, and it should work fine, e.g.: