且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么WPF绑定句柄两种不同的方式INotifyPropertyChanged的?

更新时间:2023-02-26 22:55:22

改变从UI属性视图模型可能会导致死锁的一种情况可能碰​​上双向场景年末减少递归调用。为了阻止这种情况发生,当WPF正在改变模式,将继续追踪通过INotifyPropertyChanged的变化,但这种变化将在调度程序队列中排队,而其目前的更新完成后,它会被执行。

Changing property from UI to ViewModel may lead to deadlock kind of situation which might run into end less recursive calls in two way scenarios. In order to block this from happening, when WPF is making change to model, it will continue to track changes via INotifyPropertyChanged ,but this change will be queued in dispatcher queue, and it will be executed after its current update is finished.

由于视图模型的变化不是由WPF发起,WPF将不排队的操作,它会立即执行更改。

Since the change in viewmodel is not initiated by WPF, WPF will not queue the operation, it will immediately execute the change.