You're trying to cast a ListBoxItem
to a ComboBoxItem
.
Use ComboBoxItem
in your XAML markup instead of ListBoxItem
.
<ComboBox Name="sendsmscbox" SelectionChanged="smscbox_SelectionChanged" >
<ComboBoxItem Content="All Students"/>
<ComboBoxItem Content="Selected Students"/>
</ComboBox>
Or if you really meant to use a ListBoxItem
in your XAML (probably not), then cast to the correct type in your code-behind:
ListBoxItem lbi = (ListBoxItem)((ComboBox)sender).SelectedItem;