ComboBox.SelectionChanged doesn't catch the first selection
Posted
by trnTash
on Stack Overflow
See other posts from Stack Overflow
or by trnTash
Published on 2010-03-30T09:06:38Z
Indexed on
2010/03/30
9:13 UTC
Read the original article
Hit count: 447
silverlight-3.0
|combobox
I need to fill textboxes depending on the item selected in a combobox. I fill combo async and in Completed event I have the following code
combo.ItemsSource = e.Result;
combo.DisplayMemberPath = "Name";
combo.SelectedIndex = -1;
Then in the SelectionChanged event of the combo, I catch the selected object
MyClass mc= ((ComboBox)sender).SelectedItem as MyClass;
tbxName.Text = mc.Name;
...
However, when I load the project and select any event for the 1st time, NOTHING happens. Every other time (2nd, 3rd, nth) the data is correctly caught and displayed.
So I need to know why the combo doesn't catch the first selection? That's the reason I have the code combo.SelectedIndex = -1 (when the app loads, combo is empty - selection -1 works).
© Stack Overflow or respective owner