Search code examples
wpfinotifypropertychangeddispatcher

WPF Are NotifyPropertyChangeds marshalled to the dispatcher?


If I update a property that throws a NotifyPropertyChanged on a thread other than the bound control's dispatcher is the update forcibly marshalled to this dispatcher?

BackgrounWorker.Run() => { blah.Blahness = 2; // notifies property changed on BW, is this marshalled to the dispatcher? }

Solution

  • Yes, the PropertyChanged event is automatically marshalled to the UI dispatcher, so you don't need to use Invoke to marshall it explicitly.

    Note that it is only true for change notifications on scalar properties (i.e. PropertyChanged event). Collection change notifications (INotifyCollectionChanged.CollectionChanged event) don't work that way, they must be raised on the UI thread manually. I wrote a class that does it automatically, you can find it here.