0

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

HW2015
  • 81
  • 2
  • 11

1 Answers1

1

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.

benPearce
  • 37,735
  • 14
  • 62
  • 96
  • Didn't work for me. I have now a data binding between ListBox.SelectedItem and my data context but the result is the same :-( – HW2015 Oct 25 '10 at 07:36