Reputation: 387557
What event do I have to listen for, to get notified when a user selects an option from a (editable) WPF ComboBox control?
Do I have to access the Items property first to then listen to Items.CurrentChanged
? And if so, how do I add that listener in XAML?
Upvotes: 1
Views: 5522
Reputation: 1030
if you are looking to do it in MVVM then its:
<ComboBox SelectedItem={Binding Path=SelectedItem}/>
assuming you have a SelectedItem property in your ViewModel set to the proper objectType.
Upvotes: 2
Reputation: 8022
How about the SelectionChanged event?
EDIT: Added a simple example
<ComboBox SelectionChanged="ComboBox_SelectionChanged"/>
and in code-behind:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
Upvotes: 5