WPF - Combobox SelectedItem not getting set?

后端 未结 1 1396
一个人的身影
一个人的身影 2020-12-06 11:21

I have a ComboBox that has its ItemsSource bound to a static List of options. The ComboBox is part of a form which is bound to a CustomObj

相关标签:
1条回答
  • 2020-12-06 11:46

    If the item that is selected is not the same instance that is contained in the List, you must override Equals() in the CustomObject to let the ComboBox know that it is the same object.

    If it's the same instance, maybe it's only a simple thing such as setting the BindingMode to TwoWay:

    SelectedItem="{Binding Path=CustomSettingProperty,Mode=TwoWay}"
    
    0 讨论(0)
提交回复
热议问题