Quantcast
Viewing all articles
Browse latest Browse all 18858

Update a ListCollectionView through a event becomes exception

Hello,

i have a problem with ListCollectionView.

Tried to update the items of ListCollectionView through a event, which has been fired by EventAggregator. It seems to be the problem, that i fired the event from View-A and want to update the ListCollecitonView in the View-B. So i got always the exception about Dispatcher-Thread.

From ViewModel-A:

mEventAggregator.GetEvent<DataChanged<DataType>().Publish(changedData);

From ViewModel-B:

mEventAggregator.GetEvent<DataChangedEvent<DataType>>().Subscribe(UpdateDataMethod); 
private void UpdateDataMethod(DataType changedData)
{
  var found = this.UIViewModel.DataCollectionView.OfType<DataType>().FirstOrDefault( item=> item.ID == changedData.ID );
  if(found!=null)
  {
    this.UIViewModel.DataCollectionView.Remove( found );
  }
}

Any help will be thankful!




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>