I just noticed that when changing bound properties in my ViewModel (MVVM) from a background worker thread I do not get any exceptions and the view is updated correctly. Does this mean I can safely rely on wpf databinding marshalling all changes in the ViewModel to the UI Thread? I think I have read somewhere that one should make sure (in the ViewModel) that INotifyPropertyChanged.PropertyChanged is fired on the UI thread. Has this changed in 3.5 or something?
I just noticed that when changing bound properties in my ViewModel (MVVM) from a
Share
Yes for scalars, no for collections. For collections, you’ll need a specialized collection that marshals for you, or manually marshal to the UI thread yourself via the
Dispatcher.You may have read that
INotifyCollectionChanged.CollectionChangedmust fire on the UI thread, because it’s simply not true ofINotifyPropertyChanged.PropertyChanged. Below is a very simple example that proves WPF marshals property changes for you.Window1.xaml.cs:
Window1.xaml: