WPF Are NotifyPropertyChangeds marshalled to the dispatcher?

≡放荡痞女 提交于 2019-12-12 19:03:58

问题


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? }

回答1:


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.



来源:https://stackoverflow.com/questions/6773908/wpf-are-notifypropertychangeds-marshalled-to-the-dispatcher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!