I've the following problem: if I load a simple list into ICollectionView which is bound on my wpf listbox, then CurrentChanged event being raised as I expected:
List<int> l = new List<int>();
l.Add(1);
l.Add(2);
MyCollection = CollectionViewSource.GetDefaultView(l);
MyCollection.CurrentChanged += MyCollection_CurrentChanged; // ok, it's raised
However, Imagine I'm loading data into another thread, then, I would like the same behaviors, that is raising currentChanged event, but it doesn't work:
List<int> l = new List<int>();
Task.Factory.StartNew(() =>
{
l.Add(1);
l.Add(2);
})
.ContinueWith((r) =>
{
MyCollectio = CollectionViewSource.GetDefaultView(l);
MyCollectio.CurrentChanged += MyCollectio_CurrentChanged; // ko, it isn't raised.
}, TaskScheduler.FromCurrentSynchronizationContext());
Note that I'm using TaskScheduler.FromCurrentSynchronizationContext() in order to work on UI thread, however it doesn't work. I also tried with Application.Current.Dispatcher.Invoke without luck.