How to get OnSelectionChanged ListBoxItem background change when modifying the data at the same time using a ListBox control?

StackOverflow https://stackoverflow.com/questions/4010400

문제

I have a ListBox control with an ObservableCollection instance as the control's ItemsSource property.

Everything works fine, but when I handle the control's OnSelectionChanged, my business logic modifies the collection's data and I no longer get the ListBoxItem background change you usually get when your ListBox selection changes.

Did anyone encounter the same problem ? Any solution here ?

Thanks and best regards,

Romain

도움이 되었습니까?

해결책

It sounds like you are losing your selected item reference when the list changes.

Bind your ListBox's SelectedItem to a property on your data context and handle selection changes there.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top