WPF ComboBox SelectedItem not Updating

前端 未结 3 1153
無奈伤痛
無奈伤痛 2021-01-24 11:54

I am facing a problem while working with a WPF ComboBox. My situation is that I have a ComboBox that is displaying some values. I am adding ContentControls to Combo

3条回答
  •  无人共我
    2021-01-24 12:28

    Instead of adding ContentControl directly inside the ComboBox, Use a DataTemplate(ItemsTemplate) or ItemContainerStyle. Because the automatically generated ComboBoxItem doesn't know your click because the ContentControl eats up the Mousedown and hide the ComboboxItem. ComboBox item is responsible to set the IsSelectedProperty and trigger SelectionChanged to happen.

提交回复
热议问题