开发者

Event when ComboBoxItem in ComboBox gets selected

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?


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)
{
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜