I try to get the selected value from the combo box in WPf. The data from specific table is populated into the combo. I already tried with the following code. string cmbvalue = ""; System.Windows.Controls.ComboBoxItem curItem = ((System.Windows.Controls.ComboBoxItem)Cmbfilter.SelectedItem); ID = curItem.Content;
but error occurs when I implemented this code. The error is Cmbfilter is not in the current context.
if the error is CmbFilter is not in the current context, it means that you probably misspelled the name of the combobox, or it is out of scope at the point where you use this code.
Second, the type of SelectedItem is probably not ComboBoxItem, but the item/record type of the underlaying table, which you assigned to ItemsSource.
Proposed as answer byHua ChenMonday, July 20, 2009 3:59 AM
Marked as answer byHua ChenFriday, July 31, 2009 10:44 AM
if the error is CmbFilter is not in the current context, it means that you probably misspelled the name of the combobox, or it is out of scope at the point where you use this code.
Second, the type of SelectedItem is probably not ComboBoxItem, but the item/record type of the underlaying table, which you assigned to ItemsSource.
Proposed as answer byHua ChenMonday, July 20, 2009 3:59 AM
Marked as answer byHua ChenFriday, July 31, 2009 10:44 AM