views:

133

answers:

2

I have a control that is data-bound to a list box. All of the bound properties are being updated correctly. However, the control needs to know when the selected item changes so that it can do some other cleanup. Is there an event that covers this?

A: 

There is SelectionChanged event in ListBox.

Akash Kava
No good. The detail control and the listbox don't know anything about each other. I need to do this entirely within the detail control.
Jonathan Allen
+2  A: 

You can also bind to the SelectedItem property, say with ICollectionView.CurrentItem, and set the IsSynchronizedWithCurrentItem property to True.

codekaizen
I don't see how that will give me a current item changed event.
Jonathan Allen
You can listen to the underlying collection's `CurrentChanged` event.
codekaizen
Ok, I see now. I use the CollectionViewSource.GetDefaultView(DataContext) to get the view, and that view is your ICollectionView.
Jonathan Allen
Stupid website. It won't let me give you an up vote unless you edit your answer.... or I can edit it without changing anything.
Jonathan Allen